Javascript paging from Asp:Gridview

Asked

Viewed 226 times

0

I have the following code:

Javascript:

<script src="../js/plugins/datatables/jquery.dataTables.js" type="text/javascript"></script>
    <script src="../js/plugins/datatables/dataTables.bootstrap.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('#example2').dataTable({
                "bPaginate": true,
                "bLengthChange": false,
                "bFilter": true,
                "bSort": false,
                "bInfo": false,
                "bAutoWidth": false
            });
        });
    </script>

Gridview:

<asp:GridView ID="example2" runat="server" CssClass="table table-bordered table-hover" AutoGenerateColumns="false" OnRowCreated="OnDataBound" OnPreRender="GridView1_PreRender" ShowHeaderWhenEmpty="true">
  <Columns>
    <asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="40">
      <ItemTemplate>
        <input type="hidden" id="ih1_<%#Eval("S_ID")%>" name="ih1_<%#Eval("S_ID")%>" value='<%# Container.DataItemIndex %>' />
        <input type="radio" id="rbTipo" name="rbTipo" value='<%#Eval("S_ID")%>'/>
      </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField DataField="S_Desc" />
    <asp:BoundField DataField="TS_Desc" />
  </Columns>
</asp:GridView>

My problem is that the function in Avascript does not work or at least does not show the expected results.

I wanted to show the pagination in Gridview, through the Java code that is on top. What’s wrong with this code? Is there any solution?

The pulgins are from the Adminlte website.

  • tries to download an updated version on the site Official of the plugin: http://datatables.net

  • Post the correct code, I tried to edit, but you mixed a few things in the code when you pasted it here. Edit the question and organize it better so you can help.

1 answer

0


If you are just going to put paging in gridview you have a property for this. AllowPaging="True"

If it is not that, it puts more details of the problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.