I have a datagrid w/several controls, one of which is a dropdownlist. I can databind the list, select one and save, no problem.
My problem is: When the page loads for the first time, I'd like my dropdownlists to default to the value saved for that particular column for each record shown in the datagrid. I can't get the subroutine in the code-behind that's called via onprerender to reference a value from my datagrid that's used for the findbyvalue.
Public Sub SetDropDownIndex1(ByVal sender As Object, ByVal e As System.EventArgs)
Dim ed As System.Web.UI.WebControls.DropDownList
ed = sender
ed.SelectedIndex = ed.Items.IndexOf(ed.Items.FindByValue(my_id))
End Sub
If there's just one record, I can set my_id easily, but in my case I have 15 records to display.
Also tried selectedindex to call a function instead of onprerender, but for some reason I couldn't reference the dropdownlist control in the code-behind... Is this because the ddl is within the datagrid? Thanks
My problem is: When the page loads for the first time, I'd like my dropdownlists to default to the value saved for that particular column for each record shown in the datagrid. I can't get the subroutine in the code-behind that's called via onprerender to reference a value from my datagrid that's used for the findbyvalue.
Public Sub SetDropDownIndex1(ByVal sender As Object, ByVal e As System.EventArgs)
Dim ed As System.Web.UI.WebControls.DropDownList
ed = sender
ed.SelectedIndex = ed.Items.IndexOf(ed.Items.FindByValue(my_id))
End Sub
If there's just one record, I can set my_id easily, but in my case I have 15 records to display.
Also tried selectedindex to call a function instead of onprerender, but for some reason I couldn't reference the dropdownlist control in the code-behind... Is this because the ddl is within the datagrid? Thanks