0
我有一些column.First列一個GridView是一個模板字段:在ASP.NET中的GridView上選擇全行?
...
<asp:TemplateField HeaderText="id">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# "~/mail/showMail.aspx?q="+Eval("id") %>'>Select</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
...
我想使用全行選擇,而不是這上面的TemplateField。我用這個代碼:
protected void grdList_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.cursor='pointer';this.style.textDecoration='underline';";
e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
e.Row.ToolTip = "Click to select row";
e.Row.Attributes["onclick"] =
this.Page.ClientScript.
GetPostBackClientHyperlink(this.grdList, "Select$" + e.Row.RowIndex);
}
}
但是不行。
如何使用超鏈接,而不是 「選擇$」,就像這樣:
ClientScript.
GetPostBackClientHyperlink(this.grdList, "~/mail/showMail.aspx?q=Eval(\"id\")");
全行選擇怎麼樣? – Hassan 2014-09-02 04:46:02