# VBForums CodeBank > CodeBank - C# >  Printing A Dataset In A Web Application

## Alaa

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

```
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  :Smilie: ).

hopefully this will come handy to somebody needs it  :Smilie:

----------


## Hack

Moved to the CodeBank

----------

