How do I set a Dropdown list item Programatically?
-
I have the following database table. This is a list of department names. DeptID Department 1 Administration 2 Information Technology 3 Product Development 4 Sales 5 Marketing 6 Partnerships 7 Contractor From the Employees table I read in this record: 1001 7 4 Doe Jane M 12/24/2005 12:00:00 AM False My problem is this: I’m using a web page to edit employee information. On this web form there are four drop down boxes, one each for Departments, Titles, Address Types and States. After I initialize the web page and populate the above mentioned drop down list with the necessary data. I want to take the employee record and set the drop down list to the right item in the list. How can I make ASP.NET populate the dropdown lists based on the foreign ID number contained in the employee record? I have a screen shot of what I want the data to look like in the web page, but I can't show it in this message. Thank you, Quecumber256
-
I have the following database table. This is a list of department names. DeptID Department 1 Administration 2 Information Technology 3 Product Development 4 Sales 5 Marketing 6 Partnerships 7 Contractor From the Employees table I read in this record: 1001 7 4 Doe Jane M 12/24/2005 12:00:00 AM False My problem is this: I’m using a web page to edit employee information. On this web form there are four drop down boxes, one each for Departments, Titles, Address Types and States. After I initialize the web page and populate the above mentioned drop down list with the necessary data. I want to take the employee record and set the drop down list to the right item in the list. How can I make ASP.NET populate the dropdown lists based on the foreign ID number contained in the employee record? I have a screen shot of what I want the data to look like in the web page, but I can't show it in this message. Thank you, Quecumber256
listControl.SelectedIndex = listControl.Items.IndexOf(listControl.Items.FindByValue(deptID))
Michael
I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)