When 'Edit' is clicked, I want a drop-down list to display the value that is in the cell prior to clicking 'Edit'. I use the following code to do this:
When 'Edit' is clicked, the drop-down list is blank. What am I missing?
Thanks,
BoydMT
Code:
Private Sub dgProposals_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgProposals.ItemDataBound
If e.Item.ItemType = ListItemType.EditItem Then
'ContactName dropDownList
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
Dim strContact As String = CType(drv("Contact"), String)
Dim cmbContact As DropDownList = CType(e.Item.FindControl("editContact"), DropDownList)
Try
cmbContact.SelectedIndex = cmbContact.Items.IndexOf(cmbContact.Items.FindByText(strContact))
Catch SQLexc As SqlException
lblError.Text = "Error while Generating Data. " & SQLexc.ToString()
End Try
End If
End Sub
Thanks,
BoydMT