每次呈现页面时单击的GridView行

时间:2018-10-04 18:48:02

标签: c# asp.net

基本上,每次我加载或重新加载页面时,它都会将我的gridview中的每一行都视为已被单击,因此,与之相关的代码隐藏函数对每行都调用一次,此时该行被设置为最多13行。感谢您的帮助。

protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        // Attaching one onclick event for the entire row, so that it will
        // fire SelectedIndexChanged, while we click anywhere on the row.
        e.Row.Attributes["onclick"] =
          ClientScript.GetPostBackClientHyperlink(this.GridView2, "Select$" + e.Row.RowIndex);

    }
    Console.WriteLine("");
}

0 个答案:

没有答案