vendredi 30 septembre 2016

Checkbox selected list contains only those on the screen

I have a GridView containing a list of items with a checkbox and I use the code below to "page" table (Datatables js):

$(".gvdatatable").dataTable();

The problem occurs when I check which checkboxes are selected, because at this point is only listed those that are being displayed on the screen, that is, if I select two items from page 1 and select an item on page 2, the code only considers the checkbox selected on page 2. the interesting thing is that if I go back to page 1 checkbox is still selected. GridView code:

<asp:GridView ID="dataTables" CssClass="gvdatatable table table-striped table-bordered table-hover textTable" runat="server"
                                AutoPostBack="True"
                                OnRowDataBound="Grid_RowDataBound"
                                OnPreRender="dataTables_PreRender">

<Columns>

    <asp:TemplateField>
        <HeaderTemplate>
            <asp:CheckBox ID="CheckAll" runat="server" onclick="GridSelectAllColumn(this);"/>
        </HeaderTemplate>

        <ItemTemplate>
           <asp:CheckBox ID="CheckStatus" runat="server" CssClass="chk" />
        </ItemTemplate>
    </asp:TemplateField>

    <asp:BoundField DataField="NOME" HeaderText="NAME"/>
    <asp:BoundField DataField="CARDID" HeaderText="CARDID" />
    <asp:BoundField DataField="OLD" HeaderText="OLD" />

</Columns>

Code that retrieves the checkbox:

foreach (GridViewRow viewRow in dataTables.Rows)
{
    var t = viewRow.Cells[0].FindControl("CheckStatus") as CheckBox;

    if (t.Checked)
    {
        lista.Add(t);
    }
}




Aucun commentaire:

Enregistrer un commentaire