Using jquery to implement the GridView asynchronous sorting, paging

Source: Internet
Author: User

Often use jquery.ui.tabs tags, such as we can put the backup management on a page, and the page has two tab for backup and restore, but this will be the page is bloated, each time the backup management page, the server will be all the backup restore information to the client, Then Ui.tabs will be two kinds of information folded up to display, fortunately ui.tabs to provide me with Ajax features, our each tab can directly apply another page

Such as:

<div id= "Container" >
      <ul>
          <li><a  href= "#fragment-1" ><span> Backup

< /span></a></li>
          <li><a  href= "restore.aspx" ><span> restore

</span> </a></li>
      </ul>
      </div>

However, when Restore.aspx has a server-side control, it will not be ideal when interacting with the server, such as the GridView is sorted, and paging is not possible because each interaction he will always show you the first time you load the tab state (GridView it May always show the first page), and sometimes even the entire page is filled.

To solve this problem, first think of Ajax to prevent all the referenced pages from reloading. UpdatePanel I tried it, so I thought of juery.

I'll show you how to implement the asynchronous sort of GridView with jquery, paging.

First we also put a GridView on the page, and he won't act as a real part of the page, but as a secondary HTML output, when an AJAX request comes in, we use this GridView, render for HTML output, Ajax callback function to complete the display. In order not to display the GridView I set Visible = False in PreRender and cannot set the Visible=false directly otherwise he will not be render to HTML

<body onload= "Getpagedata (1)" > <form id= "Form1" runat= "Server" > <div > <div id= ' showdat 

A ' > <asp:gridview id= "gvrestore" runat= "Server" width= "100%" pagesize= "5" datasourceid= "SqlDataSource1" autogeneratecolumns= "False" allowpaging= "true" onrowdatabound= "Gvrestore_rowdatabound" allowsorting= "true" Height= "138px" ondatabound= "Gvrestore_databound" onprerender= "Gvrestore_prerender" ><Columns> <asp:boundf Ield datafield= "id" headertext= "id" sortexpression= "id" visible= "False" ></asp:BoundField> <asp: BoundField datafield= "WorkID" headertext= "Work No." Sortexpression= "WorkID" ></asp:BoundField> <asp: BoundField datafield= "UserName" headertext= "operator name" sortexpression= "UserName" ></asp:BoundField> <asp: BoundField datafield= "Operatetype" headertext= "Operation type" sortexpression= "Operatetype" ></asp:BoundField> < Asp:boundfield datafield= "Operateway" headertext= "operation mode" Sortexpression= "Operateway" ></asp:BoundField> <asp:boundfield datafield= "operatetime" headertext= "Operation Time" sortexpression= "Operatetime" ></asp:BoundField> <asp:boundfield datafield= "Operatepath" Save path "sortexpression=" Operatepath ></asp:BoundField> <asp:boundfield datafield= "Operatereason" headertext= "Operation Reason" sortexpression= "Operatereason" ></asp:BoundField> <asp:templatefield headertext= "Select" > <ItemTemplate> <input id= "Radio1" type= Radio "name=" Rest Ore "Value= ' <% #Eval (" Operatepath ")%> '/><label for= ' Radio1 ' > Selection </label> </ite mtemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> <asp:sqlda Tasource id= "SqlDataSource1" runat= "Server" selectcommand= "select * from [Backupinfo] where operatetype= ' backup '" connecti onstring= "<%$ connectionstrings:backupconnectionstring%>" > </asp:SqlDataSource> </div> </form> </body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.