Template Columns in DataGrids
This message is really for Peter, it is something he helped me with before.
Peter, if you remember, I asked you about template columns in data grids (you can see the previous thread we had). I have a RadioButtonList in a template column in a datagrid. What I wanted to do is trigger an event on the index change of the radiobutton list and get the value. I had it worked out, and lost the code unfortunately, and now I am having problems again. This is what I have so far:
Public Sub RBLSelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Label1.Text = "Whoo Hooo"
End Sub
Public Sub CreateEvents(ByVal sender As Object, ByVal e As System.EventArgs)
Dim objRadioList As RadioButtonList = CType(sender, RadioButtonList)
Dim objDataGridItem As DataGridItem = CType(objradiolist.Parent.Parent,DataGridItem)
objRadioList = CType(dg1.FindControl("rblTest"), RadioButtonList)
If Not objRadioList Is Nothing Then
AddHandler objRadioList.SelectedIndexChanged, AddressOf RBLSelectionChanged
End If
'Gets the datagrid row index of this item:
' objDataGridItem.ItemIndex()
'Gets you the value from the first column:
Label1.Text = objDataGridItem.Cells(0).Text()
the problem is that I am getting an INVALID CAST on the radiobuttonlist declaration"
Dim objRadioList As RadioButtonList = CType(sender, RadioButtonList)
Any idea why, what did I do wrong or miss??
Thanks again for all of your help,
Jim
|