jeudi 8 février 2018

ASP.Net GridView and Jquery dataTable with checkbox contol

I am working with asp.net gridview and jquery dataTable. I have implemented jquery dataTable in gridview which is like below:

                <asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="False" class="table table-striped"
                    Width="100%">
                    <Columns>
<%--                        <asp:TemplateField>
                            <HeaderTemplate>
                                <asp:CheckBox ID="chkAll" runat="server"
                                    onclick="checkAll(this);" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="chk" runat="server"
                                    onclick="Check_Click(this)" />
                            </ItemTemplate>
                        </asp:TemplateField>--%>
                        <asp:BoundField DataField="CustomerID" HeaderText="Customer ID" />
                        <asp:BoundField DataField="ContactName" HeaderText="Name" />
                        <asp:BoundField DataField="Country" HeaderText="Country" />
                    </Columns>
                </asp:GridView>

My java script is like:

<script type="text/javascript">
    $(function () {
        $('[id*=gvCustomers]').prepend($("<thead></thead>").append($(this).find("tr:first"))).DataTable({
            "responsive": true,
            "sPaginationType": "full_numbers",
            "aoColumns": [
            null,
            null,
            { "bSortable": false }
            ]
        });
    });
</script>

I want to add checkbox in side gridview with a header checkbox for check all functionality. Jquery dataTable is not allowing template column inside grid. I need to retrieve values of the checkbox for delete purpose. I also need a link button to redirect to another page inside the grid. Any help will be thankfully accepted.

Thanks

Partha




Aucun commentaire:

Enregistrer un commentaire