我想網格視圖單擊某一行時重定向,所以我有OnRowCreated網格視圖,我不能夠重定向到我想如何從網格視圖重定向與DataKey
頁面<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'");
}
這裏我試圖設置背景顏色,當一個行被點擊和它的工作,但我如何重定向頁面,我必須重定向到ResponseMetrci.aspx頁面的msgID,正如我在下面做的。因此,我在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
你可以發佈gridview的標記嗎? – Pleun
ru在gridview中點擊一行或任何特定的控件時,重定向? – Karthik
這可能會幫助你http://stackoverflow.com/questions/331231/c-sharp-gridview-row-click – Karthik