这么菜还出来吓人真的是我的不对
关于DATAGRID分页的问题,,,因为数据表太大所以直接显示的话就会出现乱码,而选择了属性后AllowPaging后就有显示了,但只能显示第一页,我照猫画虎地添加了几条语句,我想肯定是不全不对的,就一个按钮和一个DATAGRID
大家能帮看看应该改哪里吗,
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CommonLibrary;
using System.Data.SqlClient;
namespace NetApp.Web.DigitSale
{
/// <summary>
/// WebForm6 的摘要说明。
/// </summary>
public class WebForm6 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private DataSet dataset;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
dataset = GetCheckCondition1();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);
this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private DataSet GetCheckCondition1()
{
return SqlHelper.ExecuteDataset(ConfigInfo.UniqueInstance.ConnectionString,
System.Data.CommandType.StoredProcedure, "web_checkcondition1 ");
}
private void Button1_Click(object sender, System.EventArgs e)
{
this.DataGrid1.DataSource=dataset.Tables[0].DefaultView;
this.DataGrid1.DataBind();
}
private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
DataGrid1.DataBind();
}
}
}
其实高手说最好是在存储过程里做分页的,但我太菜了,我也不会啊,
ALTER PROCEDURE dbo.web_checkcondition1
AS
select * from DigitCustSaleM