[英]Performing action on gridview cell click in asp.net C#
像這樣在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);
}
}
您可以通過單元格1的
e.Row.Cells[1]
這樣的索引來指定單元格
您可以像這樣獲取任何selected
row cell
值
protected void Gridview_SelectedIndexChanged(object sender, EventArgs e)
{
string designation = Gridview.SelectedRow.Cells[0].Text;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.