asp.net gridview - 选择行

the*_*ner 0 asp.net gridview

我希望能够单击gridview行以选择行而不是使用选择链接.

我有下面的代码使行可点击,并像一个超链接.....

    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)

    If (e.Row.RowType = DataControlRowType.DataRow) Then
        e.Row.Attributes.Add("onmouseover", "this.style.cursor='hand';this.style.textDecoration='underline';")
        e.Row.Attributes.Add("onmouseout", "this.style.textDecoration='none';")
        e.Row.Attributes.Add("onclick", ClientScript.GetPostBackClientHyperlink(Me.GridView1, "Select$" + e.Row.RowIndex.ToString()))
    End If

    End Sub
Run Code Online (Sandbox Code Playgroud)

....但后来我收到错误信息:

无效的回发或回调参数.使用配置或页面中的<%@ Page EnableEventValidation ="true"%>启用事件验证.出于安全考虑,此功能可验证回发或回调事件的参数是否来自最初呈现它们的服务器控件.如果数据有效且符合预期,请使用ClientScriptManager.RegisterForEventValidation方法注册回发或回调数据以进行验证.

有谁知道怎么克服这个?

谢谢,

the*_*ner 7

感谢帮助找到答案的另一种方式...而不是使用visibility属性我将display属性设置为none,一切正常...

<asp:CommandField ShowSelectButton="True" ItemStyle-CssClass="HiddenColumn" HeaderStyle-CssClass="HiddenColumn"/>


.HiddenColumn{display:none;} 
Run Code Online (Sandbox Code Playgroud)