【发布时间】:2018-11-21 10:25:48
【问题描述】:
【问题讨论】:
-
到目前为止你尝试了什么
-
我试图在行数据绑定事件中获取单元格值,但没有成功。
-
C#? VB.Net?您使用哪种语言?你的代码哪里有问题?可能无法运行的代码在哪里?
标签: c# html asp.net sql-server
【问题讨论】:
标签: c# html asp.net sql-server
像这样添加RowDataBound
protected void Gridview_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[1].Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(gridview, "Select$" + e.Row.RowIndex);
}
}
你可以像这样
e.Row.Cells[1]为单元格 1 提供单元格索引
您可以像这样获得任何selected row cell 值
protected void Gridview_SelectedIndexChanged(object sender, EventArgs e)
{
string designation = Gridview.SelectedRow.Cells[0].Text;
}
【讨论】: