OnItemDataBound - creating dynamicly radiobuttonlist

R

robk

Hi,
I'm working on app - doing some surveys.
From db I created dataset with two tables ("Questions"). From fisrt table
I'm binding
questions to datagrid (with their IDs in hidden column).
OnItemDataBound I'm creating DataView (from second table...):
....
DataView _ans = dsQuestionaire1.Tables["Answers"].DefaultView;
_ans.RowFilter = "ID_Ans='" + e.Item.Cells[0].Text + "'";
....
From this point I'm creating new RadioButtonlist rbl:
....
rbl.DataTextField = "Answer";
rbl.DataValueField = "ID_Ans";
rbl.ID = "rbl" + rbl_num.ToString(); //unique ID
rbl_num++;

rbl.DataSource = _odgovori;
rbl.DataBind();

e.Item.Cells[1].Controls.Add(rbl);
....

With my Button1_Click I'm trying to (access those) get selected values from
radiobuttons
....
DataGridItem dgi;

for(int i = 0; i <= DataGrid1.Items.Count -1 ; i++)
{
dgi = DataGrid1.Items;
RadioButtonList rbl = (RadioButtonList) dgi.Cells[1].Controls[1]; //*comment
string selOdg = rbl.SelectedValue;
....
*I figoured that there is no control in that cell. This also brings out an
error.

Could you please point me to some solutions.
Thanks a lot.
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top