Hi all
I hav one GridView in that i hav 2 columns With One Label and One Link Button
InvoiceId ViewInvoice by clicking on ViewInvoice Link button User can open Invoice in New Page.. For This I Bind i used following code
<Columns>
<asp:TemplateField ItemStyle-Width="15%" HeaderStyle-HorizontalAlign="Left">
<HeaderTemplate>
Invoice
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblInvoice" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="15%" HeaderStyle-HorizontalAlign="Left">
<HeaderTemplate>
Invoice Status
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblInStatus" runat="server" />
<asp:LinkButton ID="lnkstatus" runat="server" CssClass="inputHighlighted" CommandName="cmdstatus" CommandArgument = "<%# ((GridViewRow) Container).RowIndex %>" Visible="false">|<font color="black">Invoice payments</font></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>Code behind
Code behind
protected void GvInvoice_RowDataBound1(object sender, GridViewRowEventArgs e)
{
DService.IN_Invoices inv = e.Row.DataItem as DService.IN_Invoices;
if (inv != null)
{
Label lblInvoice = (Label)e.Row.FindControl("lblInvoice");
if (lblInvoice != null)
{
lblInvoice.Text = Convert.ToString(inv.In_id);
}
}
if (inv != null)
{
LinkButton lblAction = (LinkButton)e.Row.FindControl("lblAction");
int status = inv.In_current_status;
if (lblAction != null)
{
lblAction.Text = "View Invoice(PDF)";
}
protected void ViewInvoice(object sender, CommandEventArgs e)
{
int count=GvInvoice.Rows.Count;
GridViewRow row = GvInvoice.Rows[1];
Label in_id=row.Cells[1].FindControl("lblInvoice") as Label ;
if(in_id!=null)
{
string invid=in_id.Text;
string URL_Invoice = "~/Invoices/" + invid + ".pdf?in_id={0}";
Response.Write("<script>");
Response.Write("window.open('URL_Invoice','e.CommandArgument.ToString()')");
Response.Write("</script>");
}
here im trying to get invoiceId throgh lblInvoice andmy invoices are atored as same as invoiceno.Pdf... ImUnable to open That
InvoiceinnewWindowButIf i useBelowLineIts working fine.
Response.Redirect(string.Format(URL_Invoice, e.CommandArgument.ToString()));
WatShould i do to invoice get open innew window
ThanksInAdavance