OnItemDataBound - creating dynamicly radiobuttonlist

Discussion in 'ASP .Net Datagrid Control' started by robk, Jul 20, 2005.

  1. robk

    robk Guest

    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.
     
    robk, Jul 20, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Antonio D'Ottavio
    Replies:
    1
    Views:
    2,724
    Antonio D'Ottavio
    Sep 19, 2005
  2. Steven
    Replies:
    1
    Views:
    1,646
    Simon
    Jul 9, 2003
  3. Maureen Black

    OnItemDataBound issue...

    Maureen Black, Apr 4, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    395
    Maureen Black
    Apr 4, 2004
  4. DaWoE

    Creating a form dynamicly

    DaWoE, Sep 1, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    590
    DaWoE
    Sep 1, 2004
  5. Vasko Buraliev

    creating interface dynamicly

    Vasko Buraliev, Sep 22, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    136
    Ravikanth[MVP]
    Sep 22, 2003
Loading...

Share This Page