I'm using Visual Studio 2015 with SQL Server 2014, VB.
I have a GridView where the first two columns are checkboxes. I'm using the routine below to export the GridView to Excel. The issue I'm having is how to put an "X" in the first two columns whenever the checkbox is checked. As of now the first two columns
are empty when exported. My columns are named as follows:
PDF, SLDPRT, PCB Footprint, Description, Height, Comments; the first two columns are templates, all others are bound datafields.
VB:
If (E1 = True Or E2 = True) And (E3 = False) Then
Response.ClearContent()
Response.Buffer = True
Response.AddHeader("content-disposition", String.Format("inline; filename={0}Cutouts_and_Holes.xls", Request.QueryString("Data")))
If E1 = True Then Response.ContentType = "application/vnd.ms-excel"
If E2 = True And E1 = False Then Response.ContentType = "application/vnd.scalc.exe -o %1"
Dim stringWriter As New StringWriter()
Dim htmlTextWriter As New HtmlTextWriter(stringWriter)
GridView1.DataBind()
GridView1.HeaderRow.Style.Add("background-color", "#FFFFFF") 'white; middle blue #3399FF
For index As Integer = 0 To GridView1.HeaderRow.Cells.Count - 1
GridView1.HeaderRow.Cells(index).Style.Add("background-color", "#969696") 'orange, was #d17250
Next
Dim index2 As Integer = 1
GridView1.RenderControl(htmlTextWriter)
Response.Write(stringWriter.ToString())
Response.[End]()
End If
The basic question is: does anybody know how I can get an "X" to appear in the exported file where either of the first two column checkboxes are checked?
About you want to modify the value according the state of the checkbox.
You could foreach every control value, then change value according to the checkbox value.
Best Regards,
Eric Du
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
188 Points
352 Posts
Trouble exporting GridView with CheckBoxes
Feb 09, 2017 12:24 AM|Bulldog248|LINK
I'm using Visual Studio 2015 with SQL Server 2014, VB.
I have a GridView where the first two columns are checkboxes. I'm using the routine below to export the GridView to Excel. The issue I'm having is how to put an "X" in the first two columns whenever the checkbox is checked. As of now the first two columns are empty when exported. My columns are named as follows:
PDF, SLDPRT, PCB Footprint, Description, Height, Comments; the first two columns are templates, all others are bound datafields.
VB:
ASP:
The basic question is: does anybody know how I can get an "X" to appear in the exported file where either of the first two column checkboxes are checked?
Thanks!
Contributor
6730 Points
2715 Posts
Re: Trouble exporting GridView with CheckBoxes
Feb 09, 2017 06:49 AM|Eric Du|LINK
Hi Bulldog248,
According to your description, if you want to export TemplateField value, please refer to this tutorial:
Export GridView with TemplateField Column to Excel in ASP.Net:
http://www.aspsnippets.com/Articles/Export-GridView-with-TemplateField-Column-to-Excel-in-ASPNet.aspx
About you want to modify the value according the state of the checkbox.
You could foreach every control value, then change value according to the checkbox value.
Best Regards,
Eric Du
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.