Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 257985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:08:34+00:00 2026-05-11T22:08:34+00:00

I want create a button option that takes the entire datalist and converts it

  • 0

I want create a button option that takes the entire datalist and converts it to a pdf file. As anyone done this in asp.net ? Please can you show an example or direct me in the right way.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:08:35+00:00Added an answer on May 11, 2026 at 10:08 pm

    Just found a snippet of code a guy posted in forum, and though i might share with others

    Re: EXPORT DATAGRID TO PDF in C#/Asp.Net

    //*************************************************
    // 
    // Author:
    //  Ryan Van Aken (vanakenr@msn.com)
    // (C) 2009 Ryan Van Aken
    // 
    //
    // Permission is hereby granted, free of charge, to any person obtaining
    // a copy of this software and associated documentation files (the
    // "Software"), to deal in the Software without restriction, including
    // without limitation the rights to use, copy, modify, merge, publish,
    // distribute, sublicense, and/or sell copies of the Software, and to
    // permit persons to whom the Software is furnished to do so, subject to
    // the following conditions:
    // 
    // The above copyright notice and this permission notice shall be
    // included in all copies or substantial portions of the Software.
    // 
    // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    //
    //*************************************************
    
    
    
    //SQL Connection Settings -----------
    public string strConn = ConfigurationManager.ConnectionStrings["BLAH-Here"].ConnectionString;
    //-----------------------------------
    
    protected void Page_Load(object sender, EventArgs e)
    {
    //Grab the same data as the datagrid [report view] on the reporting page
    //Then set the "ContentType" to "application/vnd.ms-excel" which will generate the .XSL file
    
    //---Retrieve the Report from SQL, drop into DataSet, then Bind() it to a DataGrid
    SqlConnection conn = new SqlConnection(strConn);
    conn.Open();
    SqlDataAdapter cmd1 = new SqlDataAdapter("EXEC [dbo].[spStatReport] @CompanyID=" + Session["CompanyID"] + ", @StatReportID=" + Request.QueryString["ReportID"].ToString() + ", @StartDate='" + Request.QueryString["StartDate"].Replace("-", "/").ToString() + "', @EndDate='" + Request.QueryString["EndDate"].Replace("-", "/").ToString() + "';", conn);
    cmd1.SelectCommand.CommandType = CommandType.Text;
    DataSet dsReports = new DataSet("tblReporting");
    cmd1.Fill(dsReports);
    conn.Close();
    
    DataGrid dtaFinal = new DataGrid();
    dtaFinal.DataSource = dsReports.Tables[0];
    dtaFinal.DataBind();
    
    dtaFinal.HeaderStyle.ForeColor = System.Drawing.Color.White;
    dtaFinal.HeaderStyle.BackColor = System.Drawing.Color.DarkGray;
    dtaFinal.ItemStyle.BackColor = System.Drawing.Color.White;
    dtaFinal.AlternatingItemStyle.BackColor = System.Drawing.Color.AliceBlue;
    
    
    //---Create the File---------
    Response.Buffer = true;
    Response.ClearContent();
    Response.ClearHeaders();
    
    //---For PDF uncomment the following lines----------
    //Response.ContentType = "application/pdf";
    //Response.AddHeader("content-disposition", "attachment;filename=FileName.pdf");
    
    //---For MS Excel uncomment the following lines----------
    //Response.ContentType = "application/vnd.ms-excel";
    //Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
    
    //---For MS Word uncomment the following lines----------
    //Response.ContentType = "application/vnd.word";
    //Response.AddHeader("content-disposition", "attachment;filename=FileName.doc");
    
    //---For CSV uncomment the following lines----------
    //Response.ContentType = "text/csv";
    //Response.AddHeader("content-disposition", "attachment;filename=FileName.csv");
    
    //---For TXT uncomment the following lines----------
    //Response.ContentType = "text/plain";
    //Response.AddHeader("content-disposition", "attachment;filename=FileName.txt");
    
    
    EnableViewState = false;
    
    StringWriter sw = new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);
    
    //---Renders the DataGrid and then dumps it into the HtmlTextWriter Control
    dtaFinal.RenderControl(hw);
    
    //---Utilize the Response Object to write the StringWriter to the page
    Response.Write(sw.ToString());
    Response.Flush();
    Response.Close();
    Response.End();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a button that has a jQuery click on the fly.
I'm using RoR 3.1 and Twitter Bootstrap, and want to create a button that
I want to create a button which when clicked calls an action. I have
I want to create a button in c# with no content but just a
I want to create a Button otherthan creating it from xml layout.i want to
I want to create PayPal button with dynamic price (depending from the item) and
i want to create a button/menu in title bar on each windows explore(or in
I want to create custom button and I need it to be circle. How
I want to create a button in one of my programs. When they click
i want to create a button which works like a real back button.When i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.