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

CheckBox Columns in RadGrid

2 Answers 163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Miroslav
Top achievements
Rank 1
Miroslav asked on 03 Jun 2011, 12:48 PM
Dear Telerik development team,

is there any way to create CheckBox columns in RadGrid fully programmatically in the code-behind? 

I have List<string> collection and I would like to add RadGrid (with two columns) to my aspx page. However, I must do this fully programmatically by code-behind. Please, do not ask me why such scenario ;) . 
So, the first column should contain items from List<string> collection, and the second one should contain enabled checkboxes.
Finally, a RadButton to get which items from the RadGrid rows are selected, should be added under the RadGrid.

Can somebody help me to accomplish described scenario by code-behind only, please?
Thank you very much.

Miro

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Jun 2011, 01:07 PM
Hello Miroslav,

Check the following help documentation which explains creating a grid programmatically in code behind.
Programmatic creation.

Thanks,
Princy.
0
Miroslav
Top achievements
Rank 1
answered on 03 Jun 2011, 02:17 PM
Hi Princy,

thank you for your post. But, let's consider following situation:

 

 

RadGrid mainRadGrid = new RadGrid();

 

 

    mainRadGrid.ID =

 

@"mainRadGrid";

 


 

 

GridBoundColumn gc1 = new GridBoundColumn();

 

 

    gc1.UniqueName = "StringColumn";
    gc1.DataField =

 

"StringColumn";

 

 

    gc1.HeaderText =

 

"String column";

 

 

    gc1.DataType =

 

Type.GetType("System.String");

 

 

 

 

 

 


GridCheckBoxColumn
gc2 = new GridCheckBoxColumn();

 

 

    gc2.UniqueName=

 

"BooleanColumn";

 

 

    gc2.DataField=

 

"BooleanColumn";

 

 

    gc2.HeaderText=

 

"Boolean column";

 

 

    gc2.AllowFiltering =

 

false;

 

 

    gc2.HeaderStyle.Width = 75;

 

    gc2.DataType =

 

Type.GetType("System.Boolean");

 


mainRadGrid.MasterTableView.Columns.Add(gc1);

mainRadGrid.MasterTableView.Columns.Add(gc2);



Can you tell me what do I wrong, please? (or what improvement is required to make second column editable)
Thank you in advance.

Miro
Tags
Grid
Asked by
Miroslav
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Miroslav
Top achievements
Rank 1
Share this question
or