jeudi 12 mai 2016

assign a value to checkbox in a grid header

I have following grid

<asp:GridView ID="grdDWlocations" CssClass="table table-hover table-striped" runat="server" GridLines="None" ShowHeaderWhenEmpty="True"
    EmptyDataText="No data found..." AutoGenerateColumns="False">
    <Columns>
        <asp:TemplateField HeaderText="" Visible="true">
            <HeaderTemplate>
                <asp:CheckBox ID="allDWlocchk" runat="server" Checked="true" Width="10px" onclick="CheckAllgrdReqDW(this)"></asp:CheckBox>
            </HeaderTemplate>
            <ItemTemplate>
                <asp:CheckBox ID="chk_DWlocReq" runat="server" Checked="true" Width="5px" OnCheckedChanged="chk_Req_CheckedChangedDW_Click" />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Code">
            <ItemTemplate>
                <asp:Label ID="lbl_DWCode" runat="server" Text='<%# Bind("Ml_loc_cd") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Description">
            <ItemTemplate>
                <asp:Label ID="lbl_DWDescription" runat="server" Text='<%# Bind("Ml_loc_desc") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

I want to assign a value for 'allDWlocchk' which is header check,

how can I do this in code behind

I tried this none of the thing worked

Attempt 1 :

((CheckBox)(grdDWlocations).FindControl("allDWlocchk")).Checked = false;  

Attempt 2 :

((CheckBox).FindControl("allDWlocchk")).Checked = false; 




Aucun commentaire:

Enregistrer un commentaire