利用Ajax实现DataGrid无刷新分页(AjaxGrid)
中国开源社区
中国开源社区
DataGrid功能强大,我们只用写几行代码就能够实现复杂的页面数据显示。数据多的时候免不了要分页显示,DataGrdi本身自带分页功能,但是当数据量少的时候很方便,当大数据量时,DataGrid得分页机制就不太好了。于是在网上找到了一种比较好的利用存储过程实现分页机制(客户端想要第几页就取第几页数据,上十万级的数据查询也很快,数据量再多的时候就没试过了,等有时间把利用存储过程分页也写在blog上
)在工作中为了让客户用的更舒服点,也赶时髦,想利用Ajax来实现DataGrid无刷新分页。主要用RenderControl方法把DataGrid翻译成Html代码,然后用Web Service 返回。当然也可以用别的方法。 中国开源社区
GenericAjaxWS.asmx.cs
中国开源社区
using System; www.ossforge.com
using System.Collections; 中国开源社区
using System.ComponentModel;
中国开源社区
using System.Data; 中国开源社区
using System.Data.SqlClient;
using System.Diagnostics; www.ossforge.com
using System.Web; www.ossforge.com
using System.Web.Services; 中国开源社区
using System.Configuration; www.ossforge.com
using System.Web.UI.WebControls;
using System.Web.UI;
using System.IO; www.ossforge.com
namespace GenricAjaxWS
中国开源社区
{
[WebService(Namespace="http://localhost/GenricAjaxWS/")]
public class GenricAjaxWS : System.Web.Services.WebService
www.ossforge.com
{
中国开源社区
SqlConnection con; www.ossforge.com
SqlDataAdapter da; www.ossforge.com
SqlCommand cmd;
DataSet ds;
www.ossforge.com
public GenricAjaxWS()
{ www.ossforge.com
InitializeComponent(); 中国开源社区
con= new SqlConnection(ConfigurationSettings.AppSettings["Connect"]);
da=new SqlDataAdapter("",con); 中国开源社区
cmd=new SqlCommand("",con); 中国开源社区
ds=new DataSet("TahaSchema"); 中国开源社区
} 中国开源社区
#region Component Designer generated code
//Required by the Web Services Designer www.ossforge.com
private IContainer components = null;
www.ossforge.com
/// <summary>
www.ossforge.com
/// Required method for Designer support - do not modify www.ossforge.com
/// the contents of this method with the code editor.

