gridview如何获取主键的值
展开全部
在GridView1_RowCommand中获取主键的值: protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int OrderId = Convert.ToInt32(GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value); } 在GridView1_PageIndexChanging中获取主键的值 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { int index=GridView1.DataKeys[e.NewPageIndex].Value; } 在GridView1_RowDeleting中获取主键的值 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int index=GridView1.DataKeys[e.RowIndex].Value; } 在GridView1_RowEditing中获取主键的值 protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { int index = GridView1.DataKeys[e.NewEditIndex].Value; } 在GridView1_RowUpdating中获取主键的值 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int index = GridView1.DataKeys[e.RowIndex].Value; } 在GridView1_RowDataBound中获取主键的值 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { int index = GridView1.DataKeys[e.Row.RowIndex].Value; }责任编辑:刘小蜗
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询