S
sona Rampall via .NET 247
I am binding a radiobuttonlist to a datagrid on the ItemDataBound event. See code:
Sub dtgAccesSite_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dtgAccesSite.ItemDataBound
Dim radAcces As New RadioButtonList
radAcces.Items.Insert(0, "Oui")
radAcces.Items.Insert(1, "Non")
radAcces.Items(1).Selected = True
radAcces.Items(0).Selected = False
e.Item.Cells(3).Controls.Add(radAcces)
End Sub
And I'm trying to retrieve the radiobuttonlist value on the Button_click event e.g. Save Button found outside the datagrid. See code:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim i As Integer
Dim _item As DataGridItem
For i = 0 To dtgAccesSite.Items.Count - 1
_item = dtgAccesSite.Items(i)
Dim Usr_radio As RadioButtonList = _item.FindControl("radAcces")
Usr_radio.SelectedItem.Value
Next
End Sub
It cannot find the RadioButtonList "radAcces" anywhere in the datagrid - can anyone help - this code will work using textbox, labels, etc.
Sub dtgAccesSite_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dtgAccesSite.ItemDataBound
Dim radAcces As New RadioButtonList
radAcces.Items.Insert(0, "Oui")
radAcces.Items.Insert(1, "Non")
radAcces.Items(1).Selected = True
radAcces.Items(0).Selected = False
e.Item.Cells(3).Controls.Add(radAcces)
End Sub
And I'm trying to retrieve the radiobuttonlist value on the Button_click event e.g. Save Button found outside the datagrid. See code:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim i As Integer
Dim _item As DataGridItem
For i = 0 To dtgAccesSite.Items.Count - 1
_item = dtgAccesSite.Items(i)
Dim Usr_radio As RadioButtonList = _item.FindControl("radAcces")
Usr_radio.SelectedItem.Value
Next
End Sub
It cannot find the RadioButtonList "radAcces" anywhere in the datagrid - can anyone help - this code will work using textbox, labels, etc.