Results 1 to 2 of 2

Thread: Printing A Dataset In A Web Application

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    3

    Printing A Dataset In A Web Application

    well what funny is that i asked the question and i'm answering it!!

    anyway to anyone who faces this problem and wants to print a dataset in a web application this code in c# might help..

    it export's the dataset to an exel sheet and then u can print it.. not that i used a special page just to print called temp.aspx, but u can do it at the same form.

    the button handler cade is
    Code:
    Response.Redirect("temp.aspx");
    
    'the temp.aspx pageload code is
            try
            {
    
                int x = Global.x;
    
                //export to excel
                DataSet ds = (DataSet)Session["ds"];
                GridView1.DataSource = ds;
                GridView1.DataBind();
    
                Response.Clear();
                Response.Buffer = true;
                Response.ContentType = "application/vnd.ms-excel";
                Response.Charset = "";
                this.EnableViewState = false;
    
                System.Web.UI.HtmlTextWriter(oStringWriter);
    
                Response.Flush();
                Response.End();
                Global.x += 1;
            }
            catch (Exception ex)
            {
                
            }
    note: where Global.x is a file counter, and there is some unuseful code that i didn't show here (incase some sentences made no sense ).

    hopefully this will come handy to somebody needs it
    Last edited by Hack; Oct 30th, 2006 at 07:58 AM. Reason: Added [code] [/code] tags for more clarity and modified thread title.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Printing A Dataset In A Web Application

    Moved to the CodeBank

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width