You must Sign In to post a response.
  • Category: JQuery

    Clicking edit button in gridview on paging takes to first page instead of getting stayed in the curr

    Below is my Jquery Datatable code that i used for searching the data in gridview.Everything works fine but suppose if my gridview has 13 pages with 10 records per each page ,when i click edit in my gridview let us assume 5th page it is taking me to first page on clicking edit button from any of the page it is taking me to first page instead of staying on the current page.How can i stay in the same page on clicking edit button.

    <script type="text/javascript" src="DataTable/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="DataTable/jquery.dataTables.min.js"></script>
    <script>
    $(function () {
    // Setup - add a text input to each footer cell
    $('#<%=GridView1.ClientID %> th').each(function () {
    var title = $(this).text();
    if (title == "A Name" || title == " Name" || title == "ttl") {
    $(this).html(title + '<br/><input type="text" style="width:120px" placeholder="Search ' + title + '" />');
    }
    else {
    if (title != " ") {
    //$(this).html(title + '<br/><input type="text" style="background-color:#646464;border:none" disabled="disabled" />');
    }
    }
    });
    // DataTable
    var table = $('#<%=GridView1.ClientID %>').DataTable({
    "paging": true,
    "ordering": false,
    "info": false,
    "pageLength": 10,
    "bLengthChange": false
    });
    table.columns().every( function () {
    var that = this;
    $( 'input', this.header() ).on( 'keyup change', function () {
    if ( that.search() !== this.value ) {
    that
    .search( this.value )
    .draw();
    }
    } );
    } );
    } );
    </script>
  • #768812
    Hai Kavitha,
    It seems that the current page value is passed as 0 and that is the reason, it is taking to the first page always.
    Try to check the value of the current page index when the user clicks on the edit.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #768820
    Hi kavitha,

    As suggested by Mr. Pawan, that might be problem with the page index. Request you to debug your query in Web browser and recheck the page index.

    Hope this might be helpful to you.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


  • Sign In to post your comments