简体   繁体   中英

Can't display images in picturebox in data repeater control in C#

I can't display images in picturebox in data repeater control. my code is:

cnn.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new System.Data.DataSet();
da.Fill(ds);
bi.DataSource = ds.Tables[0];
textBox1.DataBindings.Add("Text",bi,"Emri");
textBox2.DataBindings.Add("Text", bi, "Mbiemri");
Byte[] bfoto = (Byte[])(ds.Tables[0].Rows[0]["Foto"]);
MemoryStream ms = new MemoryStream(bfoto);
Bitmap bFoto = new Bitmap(ms);
pictureBox1.DataBindings.Add("image", bi, "Foto", true);

dataRepeater1.DataSource = bi;

Here is an example of how to set image property from bitmap.

PictureBox pictureBox1 = new PictureBox();
// your code
Bitmap bFoto = new Bitmap(ms);
pictureBox1.Image = bFoto;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM