GridCheckboxColumn checkboxes don't work

3 posts, 1 answers
  1. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 02 Feb 2010 Link to this post

    I'm trying to use the RadGrid GridCheckboxColumn for the first time and the checkboxes are inert - they don't work.

    <telerik:RadGrid ID="radGrid1" runat="server" Skin="Forest"     AllowFilteringByColumn="True"                           AllowPaging="True"   
        AllowSorting="True"   
        AutoGenerateColumns="False"   
        DataSourceID="ObjectDataSource1"   
        GridLines="None"   
        ShowGroupPanel="True">  
     
        <MasterTableView AllowMultiColumnSorting="True"   
        AutoGenerateColumns="False"   
        DataSourceID="ObjectDataSource1"   
        ShowFooter="True">  
              
            <RowIndicatorColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </RowIndicatorColumn> 
     
        <ExpandCollapseColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </ExpandCollapseColumn> 
          
            <Columns> 
            <telerik:GridCheckBoxColumn UniqueName="chkCol"   
                HeaderText="<center>Get<br/>Details</center>"   
                AllowFiltering="false"   
                AllowSorting="false"   
                Groupable="false">  
            <HeaderStyle Width="40px" ForeColor="#193300" Font-Bold="true" /> 
            </telerik:GridCheckBoxColumn> 
            </Columns> 
    etc.... 

    I copied this pretty much verbatum from one of the online examples.  I searched this forum without success of finding another case like this.  Does anybody have a clue as to why the checkboxes don't work (won't check)?

    Thanks,
    Mark
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 02 Feb 2010 Link to this post

    Hello Mark,

    By default for a GridCheckBoxColumn, when the grid is in browser mode the checkbox is disabled but when the column is editable, the checkbox is enabled. Check out the following document to understand better about the various columns supported by RadGrid:

    Column types


    You could still try out the following code to enable the checkboxes in the GridCheckBoxColumn, when the grid is in browser mode.
    c#:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
        { 
            if (e.Item is GridDataItem) 
            { 
                GridDataItem item = (GridDataItem)e.Item; 
                CheckBox chk = (CheckBox)item["chkCol"].Controls[0]; 
                chk.Enabled = true
            } 
        } 

    Also another suggestion would be to use a GridTemplateColumn with CheckBox in its ItemTemplate as shown below:
    aspx:

    <telerik:GridTemplateColumn UniqueName="TempCol1"  HeaderText="TempCol1"  >  
       <ItemTemplate>  
           <asp:CheckBox ID="CheckBox1" runat="server"/>  
       </ItemTemplate>  
       <EditItemTemplate> 
           <asp:CheckBox ID="CheckBox2" runat="server" /> 
       </EditItemTemplate> 
    </telerik:GridTemplateColumn>  

    Thanks
    Princy.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 03 Feb 2010 Link to this post

    Excellent response, Princy!  Thank you!  I was going to try the template option today if I could not get the checkbox column to work.  Now I will try both just for kicks.

    Cheers!
    Mark
Back to Top