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

issue createing a checkbox column

2 Answers 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gina
Top achievements
Rank 1
Gina asked on 02 Sep 2009, 06:23 PM
I am trying to create a checkbox column from a string field that comes back from my stored procedure which returns a 1 or 0 however it does not seem to be working... can someone shed some light as to what i might be doing wrong ?

 

<telerik:GridCheckBoxColumn DataField="Monday"

 

 

HeaderText="Monday"

 

 

AllowSorting="true"

 

 

UniqueName="Monday" DataType="System.Boolean">

 

 

</telerik:GridCheckBoxColumn>

the field name from the table is called 'Monday'

thank you for any help you can give

 

2 Answers, 1 is accepted

Sort by
0
Gina
Top achievements
Rank 1
answered on 03 Sep 2009, 12:33 PM
Hi Daniel,
the below did work however its not editable? Can you tell me how I can make this editable?

<telerik:GridTemplateColumn> 

    <ItemTemplate> 

        <asp:CheckBox ID="CheckBox1" runat="server" Enabled="false" Checked='<%# Eval("myValue").ToString() == "1" %>' /> 

    </ItemTemplate> 

</telerik:GridTemplateColumn> 

 
I added the <EditItemTemplate> to make the column editable however it does not seem to work ?

<telerik:GridTemplateColumn HeaderText="Monday">
    <EditItemTemplate>
        <asp:CheckBox ID="ckEdit" runat="server" Enabled="false" Checked='<%# Eval("Monday").ToString() == "1" %>' />
    </EditItemTemplate>
    <ItemTemplate>
        <asp:CheckBox ID="CheckBox1" runat="server" Enabled="false" Checked='<%# Eval("Monday").ToString() == "1" %>' />
    </ItemTemplate>
</telerik:GridTemplateColumn>

 

 

 

 

0
Daniel
Telerik team
answered on 04 Sep 2009, 11:56 AM
Hello Gina,

When you have template column in the grid make sure that you specify the field to which you bind the control inside the template column as key for the dictionary object (passed to the InsertItem(newValues) method). For example:
<telerik:GridTemplateColumn HeaderText="Check/Uncheck" UniqueName="BoolColumn">  
   <EditItemTemplate> 
     <asp:CheckBox ID="chkBoxEdit" runat="server" Checked='<%# Bind("Bool") %>' /> 
   </EditItemTemplate> 
   <ItemTemplate> 
     <asp:CheckBox ID="chkBoxDefault" runat="server" Checked='<%# Eval("Bool") %>' /> 
   </ItemTemplate>
</telerik:GridTemplateColumn> 

Find more information about how to implement checkbox in EditItemTemplate in the following link:
Column types (GridTemplateColumn section)

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Gina
Top achievements
Rank 1
Answers by
Gina
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or