Add handlers to dynamically created radio buttons in a datagrid template column
Posted on 2005-05-16
I have a datagrid in a usercontrol with dynamically created template columns holding radio buttons in the cells. Both the rows and columns of datagrid are dynamic. Data is bound like this
dgResults.DataSource = objDataSet
Now I want to add event handler to the checkedchanged event of each radio button. I am doing it in 'dgResults_ItemCreated' event like
Dim radCol As RadioButton
Dim strMapName As String
radCol = CType(e.Item.Cells(intCnt).FindControl("rad" & strMapName), RadioButton)
If Not radCol Is Nothing Then
AddHandler radCol.CheckedChanged, AddressOf RadioButton_Click
I have defined the method 'RadioButton_Click' also.
But the event is never getting hit. What should I do in this scenario? Any reply will be greatly helpful.
Thanks in advance.