【发布时间】:2012-12-07 12:15:36
【问题描述】:
我的 asp.net 页面中有 gridview。
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true" CssClass="Gridview"
OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:ButtonField Text="VIEW" ButtonType="link" CommandName="view" />
</Columns>
</asp:GridView>
我想在新窗口中打开新页面。
因为我使用了下面的代码。(这个代码不起作用!-请检查是否有任何错误)
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("view"))
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow gvrow = GridView1.Rows[index];
String id= gvrow.Cells[1].Text;
string url = "~/Mypage.aspx?myid=" + id;
Response.Write("<script>window.open( 'www.google.com' , '-blank' );</script>");
}
}
我在运行时在 GRIDVIEW 中绑定数据 请记住这一点。
这样我就不能使用超链接字段了。
建议我使用 gridview 中的编码在新窗口中打开新页面的方法。
【问题讨论】:
标签: asp.net