This is a migrated thread and some comments may be shown as answers.

[Solved] Adding checkboxes dynamically in a radgrid

1 Answer 204 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nagesh Mynedi
Top achievements
Rank 1
Nagesh Mynedi asked on 18 Jan 2010, 10:19 AM
Here i have a requirement in which i will get the count and based on the count i should get the checkboxes added dynamically

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Jan 2010, 11:26 AM
Hello Nagesh,

I am not quite sure about your scenario. If you want to add checkboxes to template column based on count, then you can try the following code.

CS:
 
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            int count = 4; // Count 
            for (int i = 0; i < count; i++) 
            { 
                CheckBox ch = new CheckBox(); // Create checkbox instance 
                ch.ID = "checkBox"+(i+1).ToString(); 
                item["CheckBoxcolumn"].Controls.Add(ch); // CheckBoxcolumn is the column uninquname of template column 
            } 
        } 
    } 

-Shinu.
Tags
Grid
Asked by
Nagesh Mynedi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or