I have a drop down list, GroupDropDown, and a data table, GroupDataTable. I have a select statement that only produces one value, i want to set the drop down selected value to the one value in the data table. I've tried a bunch of different stuff and still can't seem to figure it out. Like most errors, I'm sure I am making a silly mistake, but here is my code:
Dim Region As String = Encryption64.Decrypt(Request.QueryString("Region"))
Dim MySqlString As String = "Select GROUPNAME, GROUPOWNERSHIP from Table1 where GROUPNAME like '%" & Region & "%'"
Dim GroupDataTable As DataTable = OleFun.GetMyDataTableString(MySqlString, 2)
GroupDropDown.DataSource = GroupDataTable
For Each row As DataRow In GroupDataTable.Rows
GroupDropDown.SelectedValue = ?
You can select a row and column from a DataTable by name or index and use that value as the
GroupDropDown.SelectedValue = GroupDataTable.Rows["myColumn"].ToString(); //or by column index GroupDropDown.SelectedValue = GroupDataTable.Rows.ToString();
GroupDropDown.SelectedValue = GroupDataTable.Rows(0)("myColumn").ToString