Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find value from dropdownlist?

Status
Not open for further replies.

Corinne

Programmer
May 15, 2001
146
US
Ok .............. so this SHOULD be simple. I have a table with only 2 fields. One is an ID field with an integer datatype. The other is a GlobalArea field with a nvarchar datatype. I want the dropdownlist to be populated with the GlobalArea field from the table but I also need to be able to retain the ID value and pass that along to fill the results to my datadrid.

The code I have to fill the datalist:

Dim o_Department As New ztblDepartment()
Dim dsDepartment As New DataSet()
dsDepartment = o_Department.GetAll
Dim dvDepartment As New DataView(dsDepartment.Tables(0), "", "DepartmentsID", DataViewRowState.CurrentRows)
For Each r In dsDepartment.Tables(0).Rows
ddlDepartment.Items.Add(r.Item(1))
Next
ddlDepartment.DataSource = dvDepartment
ddlDepartment.DataTextField = "GlobalArea"
ddlDepartment.DataValueField = "DepartmentsID"


Table example:

ID GlobalArea
1 Accounting
2 Customer Service

I want the ID values to be put into a integer variable and passed to the selectedindexchanged event. How do I do this???

Please help if you can.

Corinne
 
Not in a datagid - use this...
Dim statID As Integer = Ctype(UpdateStatusDDL.SelectedItem.Value, Integer)

...since you have already set the text and value fields.

In a datagrid - use this...
Dim tstatID As DropDownList = e.Item.Cells(6).FindControl("IncStatusDDL")
Dim getStatID As String = tstatID.SelectedItem.Value
Dim statID As Integer = Ctype(getStatID, Integer)

That was the only way i could get it working in a datagrid!

then use your vars, statID, or whichever, to perform updates or redirects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top