Pdf image does not show rest of data, only gridview. What do i change???

My pdf image shows only gridview instead of all the html stuff, like the address and everything

Heres the html codes
<%@ Page Title="" Language="C#" MasterPageFile="~/AdminMaster.Master"  EnableEventValidation="false" AutoEventWireup="true" CodeBehind="ViewInvoice.aspx.cs" Inherits="PartyCitySupplier.ViewInvoice" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
     <div class="container">
    <div class="row">
        <div class="col-xs-12">
    		<div class="invoice-title">
                <h1> <strong>PartyCity Supplies</strong></h1>
    			<h2>Invoice</h2>
      <h3 class="pull-right">Order # <asp:Label ID="lbl_OrderID" runat="server"></asp:Label></h3>

<br />	
    				  Golden Avenue Street<br />
                     Singapore, 223938<br />
                    +65 6649 2303                      
    			
    		</div>
    		<hr/>
    		<div class="row">
    			<div class="col-xs-6">
    				<address>   	
                        <strong>Address:</strong>		
    					<asp:Label ID="lblAddress" runat="server"></asp:Label>
    				</address>
    			</div>
    			<div class="col-xs-6 text-right">
    				<address>
        			<strong>Purchase Order ID:</strong>
    					<asp:Label ID="lbl_poID" runat="server"></asp:Label>
    				</address>
    			</div>
    		</div>
    		<div class="row">
    			<div class="col-xs-6">
    				<address>
    					<strong>Invoice Date:</strong>
    			<asp:Label ID="lblInvoiceDate" runat="server"></asp:Label>
    				</address>
    			</div>
    			<div class="col-xs-6 text-right">
    				<address>
    					<strong>Status:</strong>
                          <asp:Label ID="lblStatus" runat="server"></asp:Label>
    				</address>
    			</div>
    		</div>
            <div class="row">
    			<div class="col-xs-6">
    				<address>   	
                        <strong>Due Date:</strong>	
                        	 <asp:Label ID="lblDueDate" runat="server"></asp:Label>
    				</address>
    			</div>
    			<div class="col-xs-6 text-right">
    				<address>
        			<strong></strong><br/>		
    				</address>
    			</div>
    		</div>
    	</div>
    </div>
    
    <div class="row">
    	<div class="col-md-12">
          <asp:GridView ID="gvOrder" runat="server" CellPadding="6"  
     CssClass= "table table-striped table-bordered table-condensed" AutoGenerateColumns="False">
              <Columns>
                  <asp:BoundField DataField="ProdNum" HeaderText="Product No" ReadOnly="True" SortExpression="ProdNum" />
                  <asp:BoundField DataField="ProdName" HeaderText="Product Name" ReadOnly="True" SortExpression="ProdName" />
                  <asp:BoundField DataField="Qty" HeaderText="Quantity" ReadOnly="True" SortExpression="Qty" />
                  <asp:BoundField DataField="linePrice" HeaderText="Line Price" ReadOnly="True" SortExpression="linePrice" />
              </Columns>
            </asp:GridView>

            <div class="row">
    			<div class="col-xs-6">
    				<address>
    					<strong></strong>
    				</address>
    			</div>
    			<div class="col-xs-6 text-right">
    				<address>
    					<strong>Subtotal:</strong>
                         <asp:Label ID="lbl_Subtotal" runat="server"></asp:Label>
    				</address>
    			</div>
    		</div>
             <div class="row">
    			<div class="col-xs-6">
    				<address>
    					<strong></strong>
    				</address>
    			</div>
    			<div class="col-xs-6 text-right">
    				<address>
    					<strong>Shipping:</strong>
                          <asp:Label ID="lbl_Shipping" runat="server"></asp:Label>
    				</address>
    			</div>
    		</div>
             <div class="row">
    			<div class="col-xs-6">
    				<address>
    					<strong></strong>
    				</address>
    			</div>
    			<div class="col-xs-6 text-right">
    				<address>
    					<strong>Total:</strong>
                         <asp:Label ID="lbl_GrandTotal" runat="server"></asp:Label>
    				</address>
    			</div>
    		</div>

    	</div>
    </div>
            <hr />
             <asp:Button ID="btnBack" class="btn btn-default" runat="server" Text="Back" OnClick="btnBack_Click" /> <asp:Button ID="btnViewPdf" class="btn btn-default" runat="server" Text="Create PDF" OnClick="btnViewPdf_Click" />

</div>
</asp:Content>

Open in new window

And here is the code behind i did for the pdf

  protected void btnViewPdf_Click(object sender, EventArgs e)
        {
            int invoiceNo = int.Parse(Request.QueryString["InvoiceId"]);
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=Invoice_" + invoiceNo + ".pdf");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
       //   gvOrder.RenderControl(hw);
            gvOrder.RenderControl(hw);
            StringReader sr = new StringReader(sw.ToString());
            Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
            HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
            PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
            pdfDoc.Open();

            htmlparser.Parse(sr);
            pdfDoc.Close();
            Response.Write(pdfDoc);
            Response.End();
            gvOrder.AllowPaging = true;
            gvOrder.DataBind();
        }
        public override void VerifyRenderingInServerForm(Control control)
        {

        }

Open in new window

JayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sammySeltzerCommented:
Hi,

I think that the reason your htmlWorker is showing only gridview stuff is because you are only passing gridview control ID of gvOrder.

To get the rest, you to format your data into a body string and pass it to your stringReader.

Example:

Just above Response.ContentType ....

Declare the string body:

 Dim body As String = "<br />"
'Then begin to assign values from the markup:

body = body & "<div class='container'>"
body = body & " <div class='row'>"
body= body & "        <div class='col-xs-12'>"
body = body & "                <div class='invoice-title'>"
body = body & "                <h1> <strong>PartyCity Supplies</strong></h1>"
body = body & "                      <h2>Invoice</h2>"
body = body & "        <h3 class='pull-right'>Order #  " & lbl_OrderID.Text & "</h3>"
body = body & "  <br />"      
body = body & "                                Golden Avenue Street<br />"
body = body & "                       Singapore, 223938<br />"
body = body & "                      +65 6649 2303 "                     
body = body & "        </div>"

Do this all the through entire markup with the exception of the button click.

Notice how I used lbl_OrderID.Text

When you are done with stringrifying the entire form fields, then

This:
StringReader sr = new StringReader(sw.ToString());

Open in new window

becomes

StringReader sr = new StringReader(body.ToString());

Open in new window


and all the values for your form fields will be rendered.

You may adjust layout after wards.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sammySeltzerCommented:
Note, since you are using c#, you will need to add ; (semi colon) after each " (double quote).
0
JayAuthor Commented:
Thankyou so much!!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.