By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,244 Members | 1,201 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,244 IT Pros & Developers. It's quick & easy.

Export Grid View To Excel without template field

P: 62
I have Grid view which contains template fields like drop down list and text box

When i export grid view to excel 2010

The excel to which i exported grid view also contains drop down and text boxes which are in grid view.
Which i do not want.I just want value selected in drop down to be exported to excel sheet not entire drop down

My code is below for exporting
Expand|Select|Wrap|Line Numbers
  1.         Try
  4.             Response.ClearContent()
  5.             Response.Buffer = True
  6.             Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", "Salary_Revision_Approver.xls"))
  7.             Response.ContentType = "application/ms-excel"
  8.             Dim sw As New StringWriter()
  9.             Dim htw As New HtmlTextWriter(sw)
  10.             gvsrapprogrid.AllowPaging = False
  11.             gvsrapprogrid.Columns(13).Visible = False
  13.             gvsrapprogrid.HeaderRow.Style.Add("background-color", "#FFFFFF")
  14.             For i As Integer = 0 To gvsrapprogrid.HeaderRow.Cells.Count - 1
  15.                 gvsrapprogrid.HeaderRow.Cells(i).Style.Add("background-color", "#df5015")
  16.             Next
  17.             gvsrapprogrid.RenderControl(htw)
  18.             Response.Write(sw.ToString())
  20.         Catch ex As Exception
  22.             Page.ClientScript.RegisterStartupScript(Page.GetType(), "alertmesg", "<script language=javascript> alert('DATA NOT AVAILABLE TO BE VIEWED');</script>")
  24.         End Try
  26.         Response.End()
Feb 12 '15 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 9,731
I've never done what you are doing but have you tried exporting the source of the GridView instead of the GridView itself.

Is the source a DataTable?
It should contain all of the information the user provided while editing.

Feb 19 '15 #2

P: 4
I doubt that you can do this with a gridview.

Try using a Data table instead of a GridView. It can also be used for such purposes in "FastReport", there it is done very simply.
Apr 8 '20 #3

Post your reply

Sign in to post your reply or Sign up for a free account.