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();

    }

posted @ 2009-05-26 13:59  失落的狼崽  阅读(229)  评论(0编辑  收藏  举报