本文介绍了如何从DataGridView获取行ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请有人帮助我,尝试添加到datagridview的链接到另一页时我陷入困境,因为类似的代码正在工作,但我不知道如何获取我单击的行的ID.
Please someone help me, i got stuck when tried to add a link to the datagridview to another page, because the like is working but i dont know how to get the ID of the row i clicked on.
推荐答案请参见此处 [ ^ ].也许这些解决方案之一可以为您提供帮助. See here[^]. Maybe one of these solutions can help you.
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow Row = (GridViewRow)((Control)e.CommandSource).NamingContainer; int rowID = Convert.ToInt32(GridView1.DataKeys[Row.RowIndex].Value); }
您应该将primaryKey设置为GridView1.DataKeyNames .. 希望您可以使用它
you should set your primaryKey as GridView1.DataKeyNames.. I hope you can use it
更多推荐
如何从DataGridView获取行ID
发布评论