我在我的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