以下是引用片段:
其关键代码实现如下:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//显示当前的学生信息列表
this.GridView1.DataSource = DataControl.GetData("select * from 学生,班级 where 学生.班级代码=班级.班级代码");
this.GridView1.DataBind();
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
string idKey = this.GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)]["学号"].ToString();
if (e.CommandName == "Mod")
{
//传递修改的标志 跳转页面
Response.);
}
else if (e.CommandName == "Del")
{
//删除当前学生信息
DataControl.Execute("delete from 学生 where 学号='" + idKey + "'");
this.GridView1.DataSource = DataControl.GetData("select * from 学生,班级 where 学生.班级代码=班级.班级代码");
this.GridView1.DataBind();
}
}
|