I have a GridView bound to the dataset. When I click Edit button I have a drop down list bound to the different database table. Let's say in column 3 in normal mode I have Label that has value 3. When I switch to the edit mode I have the drop down in the column 3 with values 1,2,3,4,5. By default the dropdown will show the top value i.e. 1. If I click update even without selecting something in the drop down , the value of the label will be changed to 1.
Somehow when I switch to the edit mode I have to select the value in the drop down equal to the value that I have currently in the label.
I was trying the RowCommand event to enter the following code
Protected Sub GridView1_RowCommand(ByVal
sender As Object, ByVal e As System.Web.UI.WebControls.
GridViewCo
mmandEvent
Args) Handles GridView1.RowCommand
If e.CommandName = "Edit" Then
Dim index As Integer = GridView1.EditIndex
Dim row As GridViewRow = GridView1.Rows(index)
Dim dd As DropDownList = CType(row.Cells(3).FindCon
trol("ddTA
Type"), DropDownList)
dd.Text = ......
End If
End Sub
The problem is n the line
Dim dd As DropDownList = CType(row.Cells(3).FindCon
trol("ddTA
Type"), DropDownList)
dd comes up as Nothing and I cannot assin the value.
The same is in the RowEditing event.
The code
Dim index As Integer = GridView1.EditIndex
Dim row As GridViewRow = GridView1.Rows(index)
Dim dd As DropDownList = CType(row.Cells(3).FindCon
trol("ddTA
Type"), DropDownList)
works fine in the RowUpdated event.
I need to enter value of the label to the dropdown list. Does somebody have any clue?
Thank you
Start Free Trial