Datagrid Template Column Radio Button (get access to the rb control)
Posted on 2004-04-29
Hi. I have a radio button in a template column of a datagrid. All I need to know is how to get access to this to be able to set the radio button as checked or unchecked (depending on the results of a query).
I'm trying this:
Dim rbactionneeded As RadioButton = CType(e.Item.FindControl("rbactionneeded"), RadioButton)
If ansval = "Y" Then 'result from stored procedure
rbactionneeded.Checked = True
(very simplified). I'm getting an error "object reference not set to an instance of an object" right when it hits rbactionneeded.checked=true. I tried add the word "new" when declaring, but didn't work. I'm certain the rb in my grid is called rbactionnneeded because I use this to insert into the database.
This code is in the itemdatabound for the given datagrid.
Any suggestions? Am I doing this incorrectly? I am awarding 500 points because it's very urgent! Thanks!