Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. export to excel from asp.net

export to excel from asp.net

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasecssasp-netlinq
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 1414935
    wrote on last edited by
    #1

    Ok, here is what I really what to do. How to I hide the DistributorID when loaded but display it when the excel file is exported. You might be thinking why don't I delete it form the page_load then, well I can't do that cause then my cells will not match up to the database to the LinkButton1_Click event using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class manager_view_distributors : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { AlternaDB.MarketingDataContext db = new AlternaDB.MarketingDataContext(); var products = from p in db.Distributors select new { p.DistributorID, Company_Name = p.CompanyName, Address = p.AddressLine1, p.City, Zip_Code = p.ZipCode, p.State, First_Name = p.Contact1FirstName, Last_Name = p.Contact1LastName, Area_Code = p.Contact1WorkAreaCode, Phone = p.Contact1WorkNumber, Num_Stores = p.NumStores, Num_DSC = p.NumDsc }; GridView1.DataSource = products; GridView1.DataBind(); } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { GridView1.PageSize = Int32.Parse(DropDownList1.SelectedValue); this.GetData(); } private void GetData() { GridView1.DataBind(); } protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; this.GetData(); } protected void LinkButton1_Click(object sender, EventArgs e) { if (this.rdoBtnListExportOptions.SelectedIndex == 1) { // the user wants all rows exported, turn off paging // and rebing the grid before sending it to the export // utility ExportExcelColumns(); this.GridView1.PageSize = 1000000; GridView1.DataBind(); } else if (this.rdoBtnListExportOptions.SelectedIndex == 2) { // the user wants just the first 100, // adjust the PageSize and rebind ExportExcelColumns(); this.GridView1.PageSize = 100; GridView1.DataBind(); } //Current Page export else if (this.rdoBtnListEx

    S 1 Reply Last reply
    0
    • U User 1414935

      Ok, here is what I really what to do. How to I hide the DistributorID when loaded but display it when the excel file is exported. You might be thinking why don't I delete it form the page_load then, well I can't do that cause then my cells will not match up to the database to the LinkButton1_Click event using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class manager_view_distributors : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { AlternaDB.MarketingDataContext db = new AlternaDB.MarketingDataContext(); var products = from p in db.Distributors select new { p.DistributorID, Company_Name = p.CompanyName, Address = p.AddressLine1, p.City, Zip_Code = p.ZipCode, p.State, First_Name = p.Contact1FirstName, Last_Name = p.Contact1LastName, Area_Code = p.Contact1WorkAreaCode, Phone = p.Contact1WorkNumber, Num_Stores = p.NumStores, Num_DSC = p.NumDsc }; GridView1.DataSource = products; GridView1.DataBind(); } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { GridView1.PageSize = Int32.Parse(DropDownList1.SelectedValue); this.GetData(); } private void GetData() { GridView1.DataBind(); } protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; this.GetData(); } protected void LinkButton1_Click(object sender, EventArgs e) { if (this.rdoBtnListExportOptions.SelectedIndex == 1) { // the user wants all rows exported, turn off paging // and rebing the grid before sending it to the export // utility ExportExcelColumns(); this.GridView1.PageSize = 1000000; GridView1.DataBind(); } else if (this.rdoBtnListExportOptions.SelectedIndex == 2) { // the user wants just the first 100, // adjust the PageSize and rebind ExportExcelColumns(); this.GridView1.PageSize = 100; GridView1.DataBind(); } //Current Page export else if (this.rdoBtnListEx

      S Offline
      S Offline
      Samer Aburabie
      wrote on last edited by
      #2

      Hi there... I have couple of comments on your question: First of all ... Haven't you notice that you have posted a newspaper here !!! This is not a good thing ... how many members do you think will read or read your post?! None !! because no one will have the time to read all this to figure out the problem you are posting and find a solution for you !! Second of all ... When posting code in your question put it in code tags .. its easier for the readers to distinguish the question body from the code in the post. We could help if you post a problem ... not a project to be rewritten all over again or something like that ... try to rewrite your problem so others could try to help you out.

      Sincerely Samer Abu Rabie Note: Please remember to rate this post to help others whom reading it.

      U 1 Reply Last reply
      0
      • S Samer Aburabie

        Hi there... I have couple of comments on your question: First of all ... Haven't you notice that you have posted a newspaper here !!! This is not a good thing ... how many members do you think will read or read your post?! None !! because no one will have the time to read all this to figure out the problem you are posting and find a solution for you !! Second of all ... When posting code in your question put it in code tags .. its easier for the readers to distinguish the question body from the code in the post. We could help if you post a problem ... not a project to be rewritten all over again or something like that ... try to rewrite your problem so others could try to help you out.

        Sincerely Samer Abu Rabie Note: Please remember to rate this post to help others whom reading it.

        U Offline
        U Offline
        User 1414935
        wrote on last edited by
        #3

        Screw off no one what's to hear your compliants, get a life.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups