Gridview and dropdownlist
Hello
I have a dropdownlist embedded in a gridview, my problem is that when i edit a row and the drop down list appears, the default value is the first value in the list not the value of the record being edited.
I try to get the current value as follows
Protected Sub gEmployee_RowEditing ....
sStatus = gEmployee.Rows(e.NewEditIndex).Cells(3).Text
gEmployee.EditIndex = e.NewEditIndex
Bind_Grid(Sort_Field)
End Sub
and change the displayed value
Protected Sub gEmployee_PreRender ...
Dim d As DropDownList
d = gEmployee.FindControl("eEmpType")
If Not IsNothing(d) Then
d.SelectedIndex = d.Items.IndexOf(d.Items.FindByText(sStatus))
End If
End Sub
But sStatus never gets assigned a value therefore prerender always throws an exception. Can anyone suggest what i am doing wrong.
Thanks
Guy
|