1

In a asp.net project I should create RadioButtons in Run time and place them in a GridView according to my gridview rows count.The problem is that in client HTML created by asp, the groupname of each radio is different because radios are in different rows despite I made the groupname of all radios same and user can select multi radios. My C# Code:

        List<RadioButton> selectRBtns = new List<RadioButton>();              
        for (int i = 0; i < dT.Rows.Count;i++ ) //dT is my datatable
        {
            RadioButton rBtn = new RadioButton();
            rBtn.ID = "rBtn" + i.ToString();
            rBtn.GroupName = "selector";
            selectRBtns.Add(rBtn);
        }

        dT.Columns.Add("select");
        myGrid.DataSource = dT;
        myGrid.DataBind();

        for (int i = 0; i < myGrid.Rows.Count; i++)
        {
            myGrid.Rows[i].Cells[dT.Columns.Count - 1].Controls.Add(selectRBtns[i]);
        } 

please help me.

1 Answers1

-1

You need to use RowDataBound or PreRender event of grid view.

Rahul
  • 5,603
  • 6
  • 34
  • 57