Why is no one answering my queries..

A

ani

Hi,


I have a datalist control and within the Itemplate I
have a radiobuttonlist control . I am binding data to the
datalist control in Page_load . Also I have sqldatareader
object that needs to be binded to the radiobutton list. I
am not able to bind the datareader to the radiobuttonlist
control as it is within the Itemtemplate. I am new
to .Net. Could someone please let me know what I should be
doing to bind the data to the radiobuttonlist within the
Itemtemplate.
When I try binding it, I get the following error:

System.NullReferenceException: Object reference not set to
an instance of an object.

Thanks..
 
C

Craig Deelsnyder

ani said:
Hi,


I have a datalist control and within the Itemplate I
have a radiobuttonlist control . I am binding data to the
datalist control in Page_load . Also I have sqldatareader
object that needs to be binded to the radiobutton list. I
am not able to bind the datareader to the radiobuttonlist
control as it is within the Itemtemplate. I am new
to .Net. Could someone please let me know what I should be
doing to bind the data to the radiobuttonlist within the
Itemtemplate.
When I try binding it, I get the following error:

System.NullReferenceException: Object reference not set to
an instance of an object.

Thanks..

You can do so by adding an event handler for the ItemDataBound event.
In that event, you can reference the e.Item and e.Item.DataItem....you
have to find your control in the item template, so you do a

((DataRow)e.Item.DataItem).FindControl("yourctlname")

I believe....note the dataitem is cast to a DataRow as I assumed I bound
my datalist to a DataTable. Then cast this whole expression to the type
of control you are using....

Note this assumes the control you're looking for is not inside another
naming container in the template....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,016
Latest member
TatianaCha

Latest Threads

Top