private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{
DataSet ds = LoadStu();
DataGrid1.DataSource=ds.Tables["student"];
DataGrid1.DataBind();
}
}
protected DataSet LoadStu()
{
DataSet ds;
if (Cache["student"]==null)
{
SqlConnection mySqlConnection=new SqlConnection("server=MASTER;" + "database=shiyan;"
+ "uid=sa;" + "password=");
SqlDataAdapter mySqlDataAdapter=new SqlDataAdapter("select * from student",mySqlConnection);
ds=new DataSet();
mySqlDataAdapter.Fill(ds,"student");
Cache.Insert("student",ds,null,
System.Web.Caching.Cache.NoAbsoluteExpiration,TimeSpan.FromMinutes(5));
}
else
{
ds=(DataSet)Cache["student"];
}
return ds;
}
private void InitializeComponent()
{
this.cndLastName.Click += new System.EventHandler(this.cndLastName_Click);
this.cmdFirstName.Click += new System.EventHandler(this.cmdFirstName_Click);
}
protected void cmdFirstName_Click(object sender, System.EventArgs e)
{
DataSet ds=LoadStu();
DataView dv =ds.Tables["authors"].DefaultView;
dv.Sort="stu_name";
DataGrid1.DataSource=dv;
DataGrid1.DataBind();
}
private void cndLastName_Click(object sender, System.EventArgs e)
{
DataSet ds = LoadStu();
DataView dv = ds.Tables["student"].DefaultView;
dv.Sort="stu_age";
DataGrid1.DataSource=dv;
DataGrid1.DataBind();
}
运行了没错误,但什么也没有显示!为什么呢?
哪个帮我看看。