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

how to set value on checkbox colum in gridview

1 Answer 155 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alessia
Top achievements
Rank 1
Alessia asked on 13 Apr 2011, 12:13 PM
Hello,

I have a gridview in which I inserted a GridTemplateColumn with a checkbox. The grid is loaded from your code and I can not set the checkbox value in the datatable.

Help
Best regards
Alessia
<telerik:RadGrid ID="G_Permessi" runat="server" AllowPaging="true" Width="100%" Height="100%"
    AutoGenerateColumns="false" GridLines="Both" PageSize="13" AllowSorting="true"
    AllowMultiRowSelection="true">
    <ClientSettings AllowKeyboardNavigation="true" ActiveRowIndex="0">
        <Scrolling AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="True" />
        <Selecting AllowRowSelect="true" />
        <ClientEvents OnRowSelected="G_Permessi_OnRowSelected" />
    </ClientSettings>
    <AlternatingItemStyle BackColor="#C7E3E3" />
    <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" PagerTextFormat="{4} Numero record filtrati: {5}" />
    <MasterTableView runat="server" TableLayout="Fixed" DataKeyNames="IdPermesso" EditMode="InPlace">
        <Columns>
            <telerik:GridBoundColumn UniqueName="AttivoDB" DataField="Attivo" Display="false" />
            <telerik:GridBoundColumn UniqueName="IdPermesso" DataField="IdPermesso" Display="false" />
            <telerik:GridBoundColumn UniqueName="Modulo" DataField="Modulo" HeaderText="Modulo"
                meta:resourcekey="G_Permessi_Modulo">
                <HeaderStyle Width="100px" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="Permesso" DataField="Permesso" HeaderText="Permesso"
                meta:resourcekey="G_Permessi_Permesso">
                <HeaderStyle Width="100px" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="Descrizione" DataField="Descrizione" HeaderText="Descrizione"
                meta:resourcekey="G_Permessi_Descrizione">
                <HeaderStyle Width="100px" />
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn UniqueName="Attivo" DataField="Attivo" HeaderText="Attivo"
                meta:resourcekey="Grid_Attivo">
                <ItemTemplate>
                    <asp:CheckBox ID="Chk_Attivo" OnCheckedChanged="AssegnaPermesso" AutoPostBack="true"
                        runat="server" />
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
                <HeaderStyle HorizontalAlign="Center" Width="50px" />
            </telerik:GridTemplateColumn>
            
        </Columns>
    </MasterTableView>
</telerik:RadGrid>






1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 14 Apr 2011, 09:18 AM
Hello Alessia,

Give a try with the following code.

aspx:
<telerik:GridTemplateColumn>
     <EditItemTemplate>
          <asp:CheckBox ID="CheckBox1" Checked='<%# (DataBinder.Eval(Container.DataItem,"Attivo") is DBNull ?false:Eval("Attivo")) %>' runat="server" />
     </EditItemTemplate>
 </telerik:GridTemplateColumn>

and also refer the following forum which discussed the same scenario.
RadGrid Item Template Data Binding.

Thanks,
Shinu.
Tags
Grid
Asked by
Alessia
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or