我在我的asp.net页面中有gridview。在gridview buttonfield的新窗口中打开一个新页面
<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中的编码在新窗口中打开新页面。
它不在GRIDVIEW中工作。 ! :( – Patel
你得到了哪个错误? –
没有错误,但是没有任何操作在按钮上点击。 – Patel