我希望网格视图在单击一行时重定向,所以我有网格视图的 OnRowCreated 并且我无法重定向到我想要的页面
<asp:GridView ID="Grid_Messagetable" runat="server" OnRowCreated="Grid_Messagetable_RowCreated" AllowPaging="False" SelectedIndex="0"
DataKeyNames="MsgID" ShowHeaderWhenEmpty="true"
OnRowDataBound="MyGrid_RowDataBound" AutoGenerateColumns="False" AllowSorting="true"
OnSorting="gridView_Sorting" Height="16px" Width="647px"> protected void Grid_Messagetable_RowCreated(object sender, GridViewRowEventArgs e)
{
e.Row.Attributes.Add("onClick", "this.style.background='#eeff00'");
}
在这里,我尝试在单击一行时设置背景颜色并且它有效,但是我如何重定向页面,我必须使用 msgID 重定向到 ResponseMetrci.aspx 页面,就像我在下面做的那样。因此,我在 url 中传递了 msgid,以便在响应指标页面中检索它。
Eval("MsgID", "ResponseMetric.aspx?MsgID={0}") %>'
我试过这个
e.Row.Attributes["onClick"] = "location.href=
'ResponseMetric.aspx?MsgID=" + DataBinder.Eval(e.Row.DataItem, "MsgID") + "'";
但我收到以下错误
Uncaught ReferenceError: redirect is not defined
(anonymous function)Messages.aspx:774
onclick