.NET中有个GIRDVIEW的分页设置有错,说是数据源不支持服务器端的分页,请教高手!
我把GRIDVIEW的属性中已经设置为分页了,我的分页代码如下protectedvoidGridView1_PageindexChanging(objectsender,...
我把GRIDVIEW的属性中已经设置为分页了,我的分页代码如下
protected void GridView1_PageindexChanging(object sender, GridViewPageEventArgs e)
{
this.GridView1.PageIndex = e.NewPageIndex;
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=172.1.21.78;Initial Catalog=FamilyFinanceSystem;Integrated Security=TRUE";
conn.Open();
SqlCommand comm = new SqlCommand("Select * from rdParentItem", conn);
SqlDataReader dr = comm.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
} 展开
protected void GridView1_PageindexChanging(object sender, GridViewPageEventArgs e)
{
this.GridView1.PageIndex = e.NewPageIndex;
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=172.1.21.78;Initial Catalog=FamilyFinanceSystem;Integrated Security=TRUE";
conn.Open();
SqlCommand comm = new SqlCommand("Select * from rdParentItem", conn);
SqlDataReader dr = comm.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
} 展开
展开全部
sqldatareader不支持分页 改为dataset
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=172.1.21.78;Initial Catalog=FamilyFinanceSystem;Integrated Security=TRUE";
conn.Open();
SqlCommand comm = new SqlCommand("Select * from rdParentItem", conn);
SqlDataAdapter ad = new SqlDataAdapter(comm);
DataSet ds = new DataSet();
ad.Fill(ds);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=172.1.21.78;Initial Catalog=FamilyFinanceSystem;Integrated Security=TRUE";
conn.Open();
SqlCommand comm = new SqlCommand("Select * from rdParentItem", conn);
SqlDataAdapter ad = new SqlDataAdapter(comm);
DataSet ds = new DataSet();
ad.Fill(ds);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询