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

GridCheckBoxColumn

8 Answers 1369 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Moustafa
Top achievements
Rank 1
Moustafa asked on 20 Aug 2008, 04:48 PM

Hi telrik

I'm having a RadGrid that  contains a column of type  GridCheckBoxColumn 

when the grid first populated the checkboxes for the GridCheckBoxColumn type  is read only

how can I enable it.

8 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 21 Aug 2008, 04:36 AM
Hello Moustafa,

For a CheckBoxColumn, the CheckBoxes will be disabled in NormalMode and enabled only in EditMode. Instead, you can insert a CheckBox in the ItemTemplate of a TemplateColumn as shown below,  which will remain enabled in the NormalMode.
aspx:
<telerik:GridTemplateColumn > 
        <ItemTemplate> 
            <asp:CheckBox ID="CheckBox1" runat="server"/>             
        </ItemTemplate> 
</telerik:GridTemplateColumn> 
 
For more information on this, you can go through this link.

Thanks
Princy.
0
Moustafa
Top achievements
Rank 1
answered on 21 Aug 2008, 07:25 AM
Thank you very much this solve my problem
0
L
Top achievements
Rank 1
answered on 03 Sep 2008, 03:14 PM
How do I enable EditMode for a GridCheckBoxColumn?

Thanks,

L
0
Sebastian
Telerik team
answered on 03 Sep 2008, 03:27 PM
Hi L,

Built-in editing for GridCheckBoxColumn is supported out-of-the-box as you can see from this online demo of the product:

http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/DataEditing/AllEditableColumns/DefaultCS.aspx
(edit an arbitrary item in it)

If you would like to make the checkbox clickable in regular mode, consider using template column with MS CheckBox inside its edit template.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
L
Top achievements
Rank 1
answered on 03 Sep 2008, 03:49 PM
Thank you Stephen,

The issue I'm coming across when using GridTemplateColumn is that the checkbox is not changed based on the data retrieved. Such as, if I use this code:

<radG:GridTemplateColumn DataField="aBoolean" UniqueName="aBoolean" HeaderText="A Boolean">
      <ItemTemplate>
             <asp:CheckBox ID="chkBoolean" runat="server"/>            
       </ItemTemplate>
 </radG:GridTemplateColumn>

and the records retrieved have some records with true for aBoolean and some records have false for aBoolean all checkboxes which appear in the grid are set to false.

With the GridCheckBoxColumn the checkboxes are either checked or unchecked based on the value for aBoolean.

Thanks,

L
0
Missing User
answered on 03 Sep 2008, 04:32 PM
Hello L,


When embedding CheckBox controls inside a RadGrid control, you must use a data-binding expression to bind the value of the CheckBox control to the data source of the parent control. Data-binding expressions are contained within <%# and %> delimiters and use the Eval and Bind functions. The Eval function is used to define one-way (read-only) binding. The Bind function is used for two-way (updatable) binding.

Greetings,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
L
Top achievements
Rank 1
answered on 03 Sep 2008, 05:04 PM
Thanks Plamen,

Using the Eval function does retrieve the values. However, when I try to apply the expression to the control as follows the application generates an error stating it cannot parse the asp:CheckBox line:

<radG:GridTemplateColumn DataField="aBoolean" UniqueName="aBoolean" HeaderText="A Boolean">
       <ItemTemplate>
                 <asp:CheckBox ID="chkBoolean" runat="server" Checked="<%# Eval("aBoolean") %>" />
       </ItemTemplate>
</radG:GridTemplateColumn>

Is there another way in which I should use the databind expression?

Thanks,

L

0
L
Top achievements
Rank 1
answered on 03 Sep 2008, 07:22 PM
Just got it to work. It's:

<asp:CheckBox ID="chkBoolean" runat="server" Checked='<%# Convert.ToBoolean(Eval("aBoolean")) %>' />
Tags
Grid
Asked by
Moustafa
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Moustafa
Top achievements
Rank 1
L
Top achievements
Rank 1
Sebastian
Telerik team
Missing User
Share this question
or