0

so im trying to load the first 2 imageIDs from 5 galleries, so here how it works, im using a stored procedure to get the top 5 galleries (galleryID). a second stored procedure is used to load the first 2 imageIDs based on the galleryID, here is the c# code

using (api_gallery_dataDataContext apiPic = new api_gallery_dataDataContext())
            {
               var PhotoResult = from g in apiPic.getFirst5Galleries().ToArray()//load gallery ids                            
                                 let p = apiPic.getPhotosOnGalID(g.gallery_id).[B]FirstOrDefault()[/B] //gets the photo ids based on gallery id
                                  select new
                                    {                                      
                                        p.photo_id,
                                        p.photo_name
                                    };

                
                       ListView3.DataSource = PhotoResult;
                       ListView3.DataBind(); //bind items to the listview
                      
                                
               
            }

As you can see in bold im using FirstorDefault, this will clearly only load the first image id from each gallery, i need to load 2 as im then using the '#Eval("photo_id")' in the listView to load the photo, but everything i have tried is not working? i have also tried the following:

using (api_gallery_dataDataContext apiPic = new api_gallery_dataDataContext())
            {               
                var PhotoResult = from g in apiPic.getFirst5Galleries().ToArray()                               
                                  
                                  select g;

                foreach (var item in PhotoResult)
                {
                    var data = from p in apiPic.getPhotosOnGalID(item.gallery_id).ToList()
                               select new
                               {
                                   p.photo_id,
                                   p.photo_name
                               };
                    ListView3.DataSource = data.ToList();
                }
              ListView3.DataBind(); //bind items to the listview
            }

This however loads each of the images (see through debugging) but only binds the last imageID in the last gallery. Anyone know of how i can do this, or even an alternative/better way?

Regards
Barrie Grant

Edited by barriegrant1: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Mark76
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.