单击GridView上某一行的事件如何触发?

sence002 2009-05-19 05:28:38
单击GridView上某一行,触发一个事件并取得该行的主键值,这个代码该怎么写?
...全文
88 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
rmk258 2009-05-19
  • 打赏
  • 举报
回复
添加行编辑事件,然后就可以得到id

//当按下详细信息按钮时,弹出sell_open页面,并将id值传递过去
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
string id = GV.DataKeys[e.NewEditIndex].Value.ToString();

UIHelper.OpenWindow(this.Page, "Sell_open.aspx?id=" + id, 400, 500, 100, 100, "ok");

}


如果你想得到某一行某一列的值的话,支持楼上的....
ch5201314zt 2009-05-19
  • 打赏
  • 举报
回复
private void bsCustInfo_CellClick(object sender, DataGridViewCellEventArgs e)
{
int i = e.RowIndex;
bs_cust_info.Rows[i].Cells[“你想要取主键的列名"].Value.ToString();

}

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧