Subject: Webform listbox databinding to any property
Posted By: Rachel P Post Date: 10/1/2005 10:11:34 PM
I know that you can bind to any property in a listbox's DataSource in a windows form by using syntax of the format:

ListBox1.DataBindings.Add(New Binding("BackColor", MyDataSet, "Customers.Background"))


where ListBox1 is a listbox, BackColor is the custom property you want to set by binding, and Customers.Background identifies the column in the dataset MyDataSet that you want to use to dictate the BackColor property.

I've heard that you can also produce an effect similar to that described/demonstrated above the above on a listbox on a webform, though a listbox as it appears on a webform doesn't have a DataBindings property, so the syntax for achieving it must be different if so. Could any of you tell me if I'm mistaken about being able to bind any property of a listbox Web Control to a column from a dataset, and if it is possible what the syntax for achieving that should be, please? Specifically, I'd like the .Font.Bold property of each row in my listbox to be dictated by a field I'm pulling from an Oracle database into a dataset that the listbox uses as its DataSource. The best I've been able to achieve at the moment is binding the .Font.Bold property to a single value from the dataset (e.g. the first record), which makes each row appear bold or not depending on the value that happens to be the case for the 'record' I pick to associate with .Font.Bold.

Hope one of you clever lot can help!

Thanks,
Rach.

Go to topic 34272

Return to index page 462
Return to index page 461
Return to index page 460
Return to index page 459
Return to index page 458
Return to index page 457
Return to index page 456
Return to index page 455
Return to index page 454
Return to index page 453