GridView的分页、删改行操作实例
编辑行:
protected void gvCategoryList_RowEditing(object sender, GridViewEditEventArgs e)
{
gvCategoryList.EditIndex = e.NewEditIndex;
gvAdminBind();
}
取消编辑行:
protected void gvCategoryList_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvCategoryList.EditIndex = -1;
gvAdminBind();
}
编辑行,上传数据:
protected void gvCategoryList_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int P_Int_AdminID = Convert.ToInt32(gvCategoryList.DataKeys[e.RowIndex].Value.ToString());
string P_Str_Admin = ((TextBox)(gvCategoryList.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString();
string P_Str_Password = ((TextBox)(gvCategoryList.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString();
mcObj.UpdateAdminInfo(P_Int_AdminID, P_Str_Admin, P_Str_Password);
gvCategoryList.EditIndex = -1;
gvAdminBind();
}