1 Replies - 1115 Views - Last Post: 08 June 2016 - 04:45 AM Rate Topic: -----

#1 ShakyaSanjog   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 06-February 16

Picturebox in Datarepeater control cannot bind with datatable!

Posted 07 June 2016 - 11:33 PM

I am trying to show some customers details with image in datarepeater control binding with datatable.TextBox and labels are properly bind with the datatable but the for picturebox i cannot bind.

The image for the picturebox is retrieved from webservice the datatable have column [custimage] with image url location as [http://myWebaddress.com/Images/FC8C-4FCE-406A-4CB9/30.jpg].

how can i bind the datatable field with the datarepeater picturebox.I have tried many ways but can't figure out.
I have tried this :

  lblCustType.DataBindings.Add("Text", dt, custype);
            lblCustUserNo.DataBindings.Add("Text", dt, user);
            //WebClient tclient = new WebClient();
            //string url = "http://myUrl.com/Images/" + global.ObjDboperation.getClientID() + "/" + "1032.jpg";
            //Image timage = Bitmap.FromStream(new MemoryStream(tclient.DownloadData(url)));

            //picCustomer.Image = timage;
            //picCustomer.DataBindings.Add("ImageLocation", dt, "http://myUrl.com/Images/" + global.ObjDboperation.getClientID() + "/" + "1032.jpg");

            BindingSource bd = new BindingSource();
            bd.DataSource = dt;
            picCustomer.DataBindings.Add(new System.Windows.Forms.Binding("ImageLocation", bd, "custimage", true, DataSourceUpdateMode.onpropertychanged));       
            dataRepeater1.DataSource = bd;



Anyone help is appreciated.

Best Regards,
sanjog

Is This A Good Question/Topic? 0
  • +

Replies To: Picturebox in Datarepeater control cannot bind with datatable!

#2 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7241
  • View blog
  • Posts: 24,555
  • Joined: 05-May 12

Re: Picturebox in Datarepeater control cannot bind with datatable!

Posted 08 June 2016 - 04:45 AM

If the image url does not need any massaging, then try binding to the picture box ImageLocation property. If it does require some massaging, then you'll likely find it easier to derive a child class from the picture box class that exposes a custom property where you can do some of the massaging before assigning to the base picture box image location property.

I have to ask, though. This looks to be new code. Why write it in WinForms when it is at end of life, when WPF is much more current and has much more consistent binding support, as well as facilities for converters if you need to massage the bound values prior to display?
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1