求一个.net数据分栏显示的代码

来源:百度知道 编辑:UC知道 时间:2024/07/03 01:00:15

namespace WebApplication2
{
public class Edit : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
DataGrid1.AllowPaging = true;
if (!Page.IsPostBack)
{
BindGrid();
}

if(!this.IsPostBack)
{
BindGrid();
}

}
public void BindGrid()
{
SqlConnection con=Db.createConnection();
SqlDataAdapter cmd=new SqlDataAdapter("select * from stu",con);
DataSet ds=new DataSet();
ds.Tables.Add("StuInfo");
cmd.Fill(ds,"StuInfo");
this.DataGrid1.DataSource=ds.Tables["StuInfo"].DefaultView;
this.DataGrid1.DataBind();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{ InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Da