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

Programattic GridCheckBoxColumn

1 Answer 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Keith
Top achievements
Rank 1
Keith asked on 09 Sep 2014, 02:52 PM
I have a radgrid that is entirely created programatically and I'm trying to add a GridCheckBoxColumn.  I want the checkboxes to be editable upon load but they are stuck in read only mode.  I can't figure out how to make them checkable. 

ASPX:
<asp:PlaceHolder ID="phRadGrids" runat="server" />

C#:
RadGrid newGrid = new RadGrid();
newGrid.ID = "grdTesting";
newGrid.MasterTableView.AutoGenerateColumns = false;
 
GridCheckBoxColumn col_Assign = new GridCheckBoxColumn();
col_Assign.HeaderText = "Assign";
col_Assign.UniqueName = "Assign";
newGrid.MasterTableView.Columns.Add(col_Assign);
 
phRadGrids.Controls.Add(newGrid);

The checkbox column shows up fine but it's greyed out and cannot be checked.  Is there an easy way to push this into an editable mode on load?

1 Answer, 1 is accepted

Sort by
0
Keith
Top achievements
Rank 1
answered on 09 Sep 2014, 04:47 PM
foreach (GridDataItem dataItem in thisGrid.Items)
{
    foreach (GridColumn col in thisGrid.Columns)
    {
        if (col.UniqueName == "Assign")
        {
            CheckBox chkAssigned = (CheckBox)dataItem["Assign"].Controls[0];
            chkAssigned.Enabled = true;
        }
}


This did the trick.  I found it inside another thread about a different topic. 
Tags
Grid
Asked by
Keith
Top achievements
Rank 1
Answers by
Keith
Top achievements
Rank 1
Share this question
or