![]() |
| ||
| Dropdown list in ASP.NET - How to get value selected I am sure this must be very simple, but unforunately I can't figure it out. I have the following code which populates the dropdown lists from the database. This works fine. Now, when the user selects a particular employee name from the list, I want to get the Employee Id of the selected employee. i.e. I need to get the "Eid" value. I can do this if the EId is loaded in the dropdown list, but in this case only the employee name is displayed. Please let me know howI can get the Eid value even though it is not loaded in the dropdown list. I would really appreciate your help Thanks - Artee Please see code below Dim strConn As String |
| ||
| Re: Dropdown list in ASP.NET - How to get value selected cboEmpList.DataValueField = myRead.GetValue(myRead.GetOrdinal("EId")) that line is only useful if you are databinding in your case use
|
| ||
| Re: Dropdown list in ASP.NET - How to get value selected Quote:
cboEmpList.DataValueField = myRead.GetValue(myRead.GetOrdinal("EId")); |
| ||
| Re: Dropdown list in ASP.NET - How to get value selected Isn't it just easier to bind your employee id as the Value of the Dropdownlist item, and their name as the Text of the Dropdownlist item. You can receive the name of the dropdownlist by: dropdownlistname.SelectedItem.Text And the value of the dropdownlist selected item by: dropdownlistname.SelectedItem.Value So a simple: Dim strEid As String = dropdownlistname.SelectedItem.Value should do the trick as long as the item's value is the Eid. |
| ||
| Re: Dropdown list in ASP.NET - How to get value selected Quote:
:P |
| All times are GMT -4. The time now is 6:49 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC