i have created a radiobuttonlist dynamically and now i want to get the selected value of the list.
here is how i created radiobuttonlist dynamically
row = New HtmlTableRow()
cell = New HtmlTableCell
Dim rbl As New RadioButtonList
rbl.ID = "rblID"
rbl.Items.Add(New ListItem("Yes", "1"))
rbl.Items.Add(New ListItem("No", "2"))
here is how i tried to get selected value. but an error occuers
Dim c As RadioButtonList = DirectCast(FindControl("rblID"), RadioButtonList)
TextBox1.Text = c.SelectedItem.Text
error is: Object reference not set to an instance of an object. on line 2 of second coding
all these codings are done codebehind file.