如何从DataGridView获取行ID

编程入门 行业动态 更新时间:2024-10-09 13:27:15
本文介绍了如何从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

本文发布于:2023-11-22 00:31:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1615281.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:DataGridView   ID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!