How To Generate Pdf From Gridview In C#

Posted onby


may i know the reason behind it,
  1. How To Generate Pdf From Html Using Php
  2. Php Code To Generate Pdf From Database

Home / ASP.NET Forums / General ASP.NET / Web Forms Data Controls / Generate a PDF file from two gridviews using iTextSharp Generate a PDF file from two gridviews using iTextSharp [Answered] RSS 2 replies.

You can not send that content down through the Ajax Request and expect it to download on the users computer. Its because AJAX & Response.write don’t go together. By calling Response.Write() directly you are bypassing the normal rendering mechanism of ASP.NET controls. The bits you write are going straight out to the client without further processing (well, mostly…). This means that UpdatePanel can’t encode the data in its special format.

Export GridView with Paging Enabled to PDF. Below is the code to Export GridView to PDF file with Paging enabled. Firstly the GridView is again populated with data from database after setting AllowPaging to false. First the GridView is rendered into an HTML string using HtmlTextWriter and then the generated HTML is added to. Disclaimer: This site is started with intent to serve the ASP.Net Community by providing forums (question-answer) site where people can help each other. The content posted here is free for public and is the content of its poster. The site does not provide any warranties for the posted content. How to export gridview data to PDF using or Export gridview data to PDF using By: Suresh. Trace Mobile Number Try Catch VBScript Virtual Keyboard WPF bulk copy code contactus delegates dynamically page create generate script jQuery Audio Plugins jQuery Mobile jQuery Video Plugins jqGridview scroll top/bottom of div.

Alternative solutions are:

  1. Remove UpdatePanel (however, layout and the entire page requirement of yours, may not allow you to do this), or
  2. Place the button outside of UpdatePanel, or

  3. Add a PostBackTrigger to your UpdatePanel that points at the button. This works great if the button is declared statically through markup on the page, or

  4. Call ScriptManager.RegisterPostBackControl() and pass in the button that is used to Export to Excel. This is the best solution for controls that are added dynamically, such as those inside a repeating template, or

  5. Open another window (without UpdatePanels) to export to excel, use an ASPX for that of which sole purpose is to download the excel file
Active2 months ago

Hello guys i have to dynamically add multiple gridview in There are no of gridview are genereated on the basis of selection.

How To Generate Pdf From Gridview In C#

3 Answers


If I have not understood wrong from title that add multiple grid view dynamically means want to add grid view from code behind at run time.

As GridView is a class in ASP.NET C# and we can create object of it and set its properties just like other class object like follows:

and can add columns of different type like BoundField and TemplateField from code Like follows:

and finally can add this grid view object on .aspx under any container control like panel.

For adding multiple grid instance just iterate above code in loop like:

Hope I understood your requirement correctly and my explanation will be helpful for you.

Rahul - SystematixRahul - Systematix

I agree completely with @RMadd. SO is not a code-writing service, you should first try and give us something to look at and show you where you are going wrong.

But, if you have no idea where to start, one way is to add all of the empty gridviews with no visibility and set them as visible according to the selection.

That's about as vague of an answer as I can give for your vague question.

Here are some other places to look I found with Google-foo:

How To Generate Pdf From Html Using Php


Php Code To Generate Pdf From Database


Not the answer you're looking for? Browse other questions tagged c#asp.netgridview or ask your own question.