I have a datagrid cell that renders as a label when loaded, but in edit mode becomes a drop down list. I want to set the selection on the dropdown list.
I am using the OnEditCommand function to try this. Here's my code:
Code:
Sub dgImpact_Edit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
Dim FundingSource As String = CType(e.Item.FindControl("lblFundingSource"), Label).Text
GetFundingSources()
dgImpact.EditItemIndex = e.Item.ItemIndex
BindImpactGrid()
Dim ddlFundingSource As DropDownList = CType(e.Item.FindControl("ddlFundingSource"), DropDownList)
ddlFundingSource.SelectedValue = FundingSource
End Sub
This gives me the dreaded "Object reference not set to an instance of an object" error.
What am I missing? Thanks in advance for your comments.
- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.