G
Guest
Can someone please tell me who I get the selectedindex of a dropdown in a
datagrid???
I have the following code and it works but it doesn't select the correct
value when I edit the dropdown list!
Thanks
Dim Myconn As New
SqlConnection(ConfigurationSettings.AppSettings("strConn"))
Dim cmd As New SqlCommand("SelectOffice", Myconn)
If e.Item.ItemType = ListItemType.EditItem Then
cmd.CommandType = CommandType.StoredProcedure
Myconn.Open()
Dim add_Office As DropDownList
Dim pageID = CInt(CType(e.Item.FindControl("pageID"),
TextBox).Text)
'Populates Office DropDownList with office names
add_Office = CType(e.Item.FindControl("DDLeditOffice"),
DropDownList)
add_Office.DataSource =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
add_Office.DataTextField = "offName"
add_Office.DataValueField = "officeID"
add_Office.DataBind()
add_Office.SelectedIndex =
Myconn.Close()
datagrid???
I have the following code and it works but it doesn't select the correct
value when I edit the dropdown list!
Thanks
Dim Myconn As New
SqlConnection(ConfigurationSettings.AppSettings("strConn"))
Dim cmd As New SqlCommand("SelectOffice", Myconn)
If e.Item.ItemType = ListItemType.EditItem Then
cmd.CommandType = CommandType.StoredProcedure
Myconn.Open()
Dim add_Office As DropDownList
Dim pageID = CInt(CType(e.Item.FindControl("pageID"),
TextBox).Text)
'Populates Office DropDownList with office names
add_Office = CType(e.Item.FindControl("DDLeditOffice"),
DropDownList)
add_Office.DataSource =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
add_Office.DataTextField = "offName"
add_Office.DataValueField = "officeID"
add_Office.DataBind()
add_Office.SelectedIndex =
Myconn.Close()