protected
void
Page_Load(
object
sender, EventArgs e)
{
if (!Page.IsPostBack)
{
deptDataBind();
}
}
// 数据绑定到控件
protected void deptDataBind() {
//这是一个动态绑定到控件的函数
}
// 点击编辑进入到编辑状态
public void dept_Edit(Object sender, GridViewEditEventArgs e)
{
dept.EditIndex = (int)e.NewEditIndex;
deptDataBind();
}
// 删除数据控件上一行
public void dept_Delete(Object sender, GridViewDeleteEventArgs e)
{
Dept _dept = new Dept();
int Dept_ID = Int32.Parse(((Label)dept.Rows[e.RowIndex].Cells[0].Controls[0]).Text);
if (_dept.Del(Dept_ID) == 1)
{
Response.Write("<script>alert('删除成功!');</script>");
}
else
{
Response.Write("<script>alert('删除失败!');</script>");
}
deptDataBind();
}
// 取消数据控件上编辑
public void dept_Cancel(Object sender, GridViewCancelEditEventArgs e)
{
dept.EditIndex = -1;
deptDataBind();
}
// 把数据控件上的数据更新到数据据库中
public void dept_Update(Object sender, GridViewUpdateEventArgs e)
{
dept.FooterRow.Enabled = false;
Dept _dept = new Dept();
int dept_ID = Int32.Parse(((Label)dept.Rows[e.RowIndex].Cells[0].Controls[0]).Text);
string dept_Name=((TextBox)dept.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
// ……进行相关的更新打操作
deptDataBind();
}
// 进行分页显示
public void dept_PageIndexChanging( object sender, GridViewPageEventArgs e)
{
dept.PageIndex = e.NewPageIndex;
deptDataBind();
}
{
if (!Page.IsPostBack)
{
deptDataBind();
}
}
// 数据绑定到控件
protected void deptDataBind() {
//这是一个动态绑定到控件的函数
}
// 点击编辑进入到编辑状态
public void dept_Edit(Object sender, GridViewEditEventArgs e)
{
dept.EditIndex = (int)e.NewEditIndex;
deptDataBind();
}
// 删除数据控件上一行
public void dept_Delete(Object sender, GridViewDeleteEventArgs e)
{
Dept _dept = new Dept();
int Dept_ID = Int32.Parse(((Label)dept.Rows[e.RowIndex].Cells[0].Controls[0]).Text);
if (_dept.Del(Dept_ID) == 1)
{
Response.Write("<script>alert('删除成功!');</script>");
}
else
{
Response.Write("<script>alert('删除失败!');</script>");
}
deptDataBind();
}
// 取消数据控件上编辑
public void dept_Cancel(Object sender, GridViewCancelEditEventArgs e)
{
dept.EditIndex = -1;
deptDataBind();
}
// 把数据控件上的数据更新到数据据库中
public void dept_Update(Object sender, GridViewUpdateEventArgs e)
{
dept.FooterRow.Enabled = false;
Dept _dept = new Dept();
int dept_ID = Int32.Parse(((Label)dept.Rows[e.RowIndex].Cells[0].Controls[0]).Text);
string dept_Name=((TextBox)dept.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
// ……进行相关的更新打操作
deptDataBind();
}
// 进行分页显示
public void dept_PageIndexChanging( object sender, GridViewPageEventArgs e)
{
dept.PageIndex = e.NewPageIndex;
deptDataBind();
}