Why is no one answering my queries..

  • Thread starter Thread starter ani
  • Start date Start date
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..
 
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

Back
Top