Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

selecting gridview columns to download to excel file

Status
Not open for further replies.

hedgracer

Programmer
Mar 21, 2001
186
US
I have the following code to download a gridview to an excel file:

public static void ExportExcelFile(Control htmlData, string filename)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=" + filename + ".xls");
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
htmlData.RenderControl(htmlWrite);
HttpContext.Current.Response.Write(stringWrite.ToString());
HttpContext.Current.Response.End();
}

My problem is that I need to delete the last column from the download (there are six columns total including the one I need to delete). Is there any way to do this in ASP.NET 2.0? Thanks for any help in advance

Dave

 
Either don't bind the last column (by not including it in the sql statement or removing it from the GridView's column section) or hide each column cell using it's Visible property.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top