locked
Datatable RRS feed

  • Question

  • User-1499457942 posted

    Hi

      I have below code but it is not showing in Jquery Datatable

    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContentPlaceHolder" runat="server">
        <script type="text/javascript" charset="utf-8">
            $('#gvwInflator').dataTable({
                "ordering": false
            });
        </script>
    </asp:Content>
    
    
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myAddModal">Add New</button><br /><br />
        <div class="row">  
            <div class="col-lg-12 "> 
                <div class="table-responsive">
                    <asp:GridView ID="gvwInflator" OnPreRender="gvwInflator_PreRender" runat="server" DataKeyNames="Code"
                    CssClass="table table-bordered table-striped" AutoGenerateColumns="false" OnRowCommand="gvwInflator_RowCommand"
                    ClientIDMode="Static" BorderWidth="1px"  
                    BorderStyle="None" BorderColor="#DEBA84" HeaderStyle-CssClass="GridHeader" 
                    EmptyDataText="No Records Found!" EmptyDataRowStyle-ForeColor="Red" EmptyDataRowStyle-CssClass ="gvEmpty" >
                    <HeaderStyle ForeColor="White" Font-Bold="True" BackColor="#428bca"></HeaderStyle>
                    <Columns>
                        <asp:TemplateField HeaderText="Code">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lblCode" Text='<%#Eval("Code") %>'></asp:Label>
                                <asp:HiddenField ID="hdfEntryNo" runat="server" Value='<%# Bind("EntryNo") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Inf">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lblInf" Text='<%#Eval("Inf") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Action">
                            <ItemTemplate>
                                <asp:linkbutton id="btnEdit"  ToolTip="Update Record" CommandName="EditRow" runat="server" CssClass="clslnkbutton"/> 
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    </asp:GridView>
                </div>
            </div>
        </div>
    
    
    protected void gvwInflator_PreRender(object sender, EventArgs e)
            {
                if (gvwInflator.Rows.Count > 0)
                {
                    gvwInflator.UseAccessibleHeader = true;
                    gvwInflator.HeaderRow.TableSection = TableRowSection.TableHeader;
                }
            }

    Thanks

    Thursday, August 16, 2018 3:52 PM

Answers

  • User-1499457942 posted

    Resolved . $(document).ready(function () { }); was not given

    $(document).ready(function () {
    $('#gvwInflator').dataTable({
    "ordering": false
    });
    });

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 16, 2018 3:56 PM