I want the grid view to redirect when a row is clicked, so I have the OnRowCreated for the grid view and I am not able to redirect to the page I wanted
<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'");
}
Here I tried to set background color when a row is clicked and it worked but how can I redirect the page, I have to redirect to ResponseMetrci.aspx page with the msgID, Just as I am doing below. So I pass the msgid in the url so that I retreive that in the response metric page.
Eval("MsgID", "ResponseMetric.aspx?MsgID={0}") %>'
i tried this
e.Row.Attributes["onClick"] = "location.href=
'ResponseMetric.aspx?MsgID=" + DataBinder.Eval(e.Row.DataItem, "MsgID") + "'";
but I am getting the error below
Uncaught ReferenceError: redirect is not defined
(anonymous function)Messages.aspx:774
onclick