Click here to Skip to main content
15,916,693 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys
i want to bind a image list from database i am getting the image name but image not coming is any body can help me

WhatsApp Image 2019-03-09 at 11.53.36 AM.jpeg - pCloud[^]

this is how i getting the out put but i want to get the image also

What I have tried:

public void ListimageGalery()
       {

           ImageList myimagelistsmall = new ImageList();
           ImageList myimageListLarge = new ImageList();
           ImageList myimagelist = new ImageList();

           ListImage.SmallImageList = myimagelistsmall;
           ListImage.LargeImageList = myimageListLarge;

           myimagelist.ImageSize = new Size(50, 50);
           myimagelistsmall.ImageSize = new Size(32, 32);
           myimageListLarge.ImageSize = new Size(80, 80);
           try
           {
               con = new SqlConnection(connectionpath);
               SqlDataAdapter dataAdapter = new SqlDataAdapter(new SqlCommand("SELECT StockItemImage,STKDESCP FROM Tbl_STKMaster", con));
               DataSet dataSet = new DataSet();
               dataAdapter.Fill(dataSet);

               ListImage.Items.Clear();
               myimageListLarge.Images.Clear();
               myimagelistsmall.Images.Clear();
              foreach(DataRow dr in dataSet.Tables[0].Rows)
               {
                   try
                   {
                       Byte[] data = new Byte[0];
                       data = (Byte[])(dataSet.Tables[0].Rows[0]["StockItemImage"]);
                       MemoryStream mem = new MemoryStream(data);
                       myimagelist.Images.Add(Image.FromStream(mem));
                       myimagelistsmall.Images.Add(Image.FromStream(mem));
                       myimageListLarge.Images.Add(Image.FromStream(mem));


                   }
                   catch (Exception ex) { MessageBox.Show(ex.Message); }
                   ListImage.LargeImageList = myimageListLarge;
                   ListImage.Items.Add(dataSet.Tables[0].Rows[0]["STKDESCP"].ToString());
                   ListImage.View = View.LargeIcon;
                   //ListImage.SmallImageList = myimagelist;
                   //ListImage.Items.Add(dataSet.Tables[0].Rows[0]["STKDESCP"].ToString());
               }
Posted
Comments
[no name] 9-Mar-19 8:46am    
You're on your own. You should have started with "one" image, and built up from there. Instead, there's a pile of useless code and an unknown data source.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900