datarow[] array as datasource for RadioButtonList

C

Christian H

Hello.

I'm using the getChildRows method, in order to get the records related to my
current record:
DataRow[] myRowArray = dataItem.GetChildRows("myRelation");

Then I add this as a datasource:
RadioButtonList rbl=new RadioButtonList();
rbl.DataSource=myRowArray ;
rbl.DataBind();

My problem is when I want to set rbl.DataTextField property, so that I can
choose which column that should display a string related to the
radiobuttons.

I've tried:
rbl.DataTextField="[0]";
and
rbl.DataTextField="myColumn";

Neither of these works, as I get an error that there is no property with
either of these names.
I'm not sure if it is possible to use a datarow array as a datasource.
I've been struggeling with this for almost a week now, without any luck
finding my answer.

Regards C.H
 
R

Rory

I am not sure if this is what you are trying to do, but to
set items in a radionbutton list, you need to loop through
each item individually to set its properties.

eg

Dim lst As ListItem
For Each lst In RadioButtonList1.Items
lst.Selected = True
lst.Text = "Option 1"
lst.Value = 1
Next

for further info:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/vbcon/html/vbtsksettingselectioninlistbox.asp

Rory
 

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

Top