Reputation: 13
I have an asp GridView from where, I am using RowCommand and take some value from this page to another page and I want to open that page on to new window.
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Trans")
{
Response.Redirect("APIwiserecharge.aspx?
DisplayID="objdl.Encode(e.CommandArgument.ToString()));
}
}
and at the .aspx page i m using this.
<asp:TemplateField HeaderText="APIDetails" ItemStyle-Width="200px">
<ItemTemplate>
<asp:LinkButton ID="trans" runat="server"CommandName="TransText="Details"
CommandArgument = '<%#Eval("DisplayID") %>'>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
Upvotes: 0
Views: 1329
Reputation: 11154
Please try with the below code snippet.
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Trans")
{
Response.Write("<script>window.open('APIwiserecharge.aspx?DisplayID=' + objdl.Encode(e.CommandArgument.ToString()) ,'_blank');</script>");
//OR
ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow1", "window.open('APIwiserecharge.aspx?DisplayID=" + objdl.Encode(e.CommandArgument.ToString()) + "');",true);
//OR
Page.ClientScript.RegisterStartupScript(GetType(), "OpenWindow1", "window.open('APIwiserecharge.aspx?DisplayID=" + objdl.Encode(e.CommandArgument.ToString()) + "');", true);
}
}
Upvotes: 1