我是 ASP.NET 的新手
我尝试做的是在 lblProposedID 字段中捕获唯一 ID (ProposedID),并将其传递到另一个页面。
GridView 中的标签
<asp:TemplateField HeaderText="ID"
SortExpression="ID" ItemStyle-Width="5%">
<ItemTemplate>
<asp:Label ID="lblProposedID" runat="server"
Text='<%#Eval("ProposedID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:TemplateField>
代码背后
private void GridView1_RowCreated(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
String rColor;
System.Drawing.ColorConverter colConvert = new ColorConverter();
if (e.Row.RowType == DataControlRowType.DataRow)
{
int RowNum = e.Row.RowIndex;
if (RowNum % 2 == 1)
{
rColor = "#FFFFFF";
//e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#DDDDDD'");
}
else
{
rColor = "#F5F5F5";
//e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='" ++ "'");
}
e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(rColor);
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='" + rColor + "'");
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#00FFFF'");
e.Row.Attributes.Add("onclick", "window.open('popup.aspx?ProposedID=" + (Label) e.Row.FindControl("lblProposedID") +
"','cal','width=600,height=300,left=270,top=180')");
//e.Row.Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);
}
}
这是我无法让它工作的线路。
e.Row.Attributes.Add("onclick", "window.open('popup.aspx?textbox={0}" + (Label)e.Row.FindControl("lblProposedID") +
"','cal','width=600,height=300,left=270,top=180')");
请帮忙。提前致谢。