export to excel from asp.net
-
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
-
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
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.
-
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.
Screw off no one what's to hear your compliants, get a life.