Set Value for Dropdown list box in Visual Basic.net web form

gem1204

New member
Joined
Sep 30, 2006
Messages
3
Programming Experience
1-3
:( Visual basic.net webform
I have a web form with a drop down list that is bound to an sql server table. The drop down list is populated as it should be with all the values. The drop down list box contains a list of priorities ie 1,2,3,4. When the web form is opened I want to populate the text boxes on the form which I have done with no problem using DataBinder.Eval expressions. I also want to set the value of the dropdown list box so that the correct priority is set and displayed and I'm have a problem.

This is type of expression I’m using to fill all of my other text boxes which all work:
DataBinder.Eval(DataSetMyrtaFamily1, "Tables[Proc_GetPictureInfo].DefaultView.[0].WebUrl")

I also want to set the value of my dropdown list box to the value that is stored in the database. I’m using this expression but I can’t get it to work.
Me.DropDownListPriority.Items.FindByText(DataBinder.Eval(DataSetMyrtaFamily1, "Tables[Proc_GetPictureInfo].DefaultView.[0].Priority")).Selected = True

I have tried both FindByText and FindByValue and neither one works.

My dropdown list’s DataTextField is set to a field called description which is a varChar field. The dropdownlist’s DataValueField is set to a field called priority which is an integer field and contains numeric values 1,2,3,4 or 5. I have verfied that my dropdown list is being populated correctly so I don’t think data binding is a problem.

Can someone please help me in setting the value of my dropdown list when my data is loaded?

Thanks
 
Back
Top