Click here to Skip to main content
15,881,600 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Can we force to make button click event happen without actually clicking? Pin
sudevsu10-Mar-15 7:41
sudevsu10-Mar-15 7:41 
AnswerRe: Can we force to make button click event happen without actually clicking? Pin
deepankarbhatnagar10-Mar-15 22:58
professionaldeepankarbhatnagar10-Mar-15 22:58 
QuestionAn existing connection was forcibly closed by the remote host in wcf Pin
kesava narayana9-Mar-15 19:00
kesava narayana9-Mar-15 19:00 
AnswerRe: An existing connection was forcibly closed by the remote host in wcf Pin
Kornfeld Eliyahu Peter9-Mar-15 20:23
professionalKornfeld Eliyahu Peter9-Mar-15 20:23 
Questionhow to bind html controls without using MVC html helpers? Pin
Tridip Bhattacharjee9-Mar-15 5:11
professionalTridip Bhattacharjee9-Mar-15 5:11 
AnswerRe: how to bind html controls without using MVC html helpers? Pin
F-ES Sitecore9-Mar-15 5:21
professionalF-ES Sitecore9-Mar-15 5:21 
QuestionFuzzy Set Classes (aspx.cs) Pin
sudabeh39-Mar-15 1:49
sudabeh39-Mar-15 1:49 
QuestionHow do I format the export of Formview data to Excel Pin
Member 109587798-Mar-15 15:34
Member 109587798-Mar-15 15:34 
CSS
I'm using Visual Web Developer 2010 Express with SQL Server 2008, VB code behind.  Yesterday I had an issue with Gridview, today it is with Formview.

I'm exporting the contents of Formview to Excel and have a problem with the formatting.  One of my Formview cells contains component size data such as 0402, 0603, 0805 and displays correctly in Formview.  When that cell exports to Excel it displays as 402, 603 and 805.  Another cell contains a list of ECO numbers such as 4203,4204,4205 and exports as 420,342,044,205.  The page I'm exporting has two Formviews and Formview2 has similar potential issues.  What can I do to correct the export to Excel to show the data the way it appears in Formview?  The difference between Gridview and Formview is different enough that the solution for Gridview does not seem to apply to Formview.

Update: I should mention that inside Formview are numerous labels that actually contain the data I need formatted.  Is it possible to "format" the output of these labels?

vb code:
<pre lang="vb">    Protected Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click     'Export to Excel
        Dim lbl1 As Label = FormView1.FindControl("PART_NUMBERLabel")
        Response.ClearContent()
        Response.Buffer = True
        Response.AddHeader("content-disposition", String.Format("attachment; filename={0}.xls", lbl1.Text))
        Response.ContentType = "application/vnd.ms-excel"
        Dim stringWriter As New StringWriter()
        Dim stringWriter1 As New StringWriter()
        Dim htmlTextWriter As New HtmlTextWriter(stringWriter)
        Dim htmlTextWriter1 As New HtmlTextWriter(stringWriter1)
        FormView1.DataBind()
        FormView1.HeaderRow.Style.Add("background-color", "#FFFFFF")    'white; middle blue #3399FF
        For index As Integer = 0 To FormView1.HeaderRow.Cells.Count - 1
            FormView1.HeaderRow.Cells(index).Style.Add("background-color", "#969696")   'orange, was #d17250
        Next
        Dim index2 As Integer = 1
        FormView1.RenderControl(htmlTextWriter)
        Response.Write(stringWriter.ToString())
        If FormView2.DataItemCount <> 0 Then
            FormView2.DataBind()
            FormView2.HeaderRow.Style.Add("background-color", "#FFFFFF")    'white; middle blue #3399FF
            For index As Integer = 0 To FormView2.HeaderRow.Cells.Count - 1
                FormView2.HeaderRow.Cells(index).Style.Add("background-color", "#969696")   'orange, was #d17250
            Next
            index2 = 1
            FormView2.RenderControl(htmlTextWriter1)
            Response.Write(stringWriter1.ToString())
        End If
        Response.[End]()
    End Sub


asp code for Package_Size:

<asp:label id="Package_SizeLabel" runat="server"
="" text="<%# Bind("Package_Size") %>" width="250px">

asp code for ECO data (UserField02):

<asp:label id="UserField02Label" runat="server"
="" text="<%# Bind("UserField02") %>" width="250px">

Thanks!
AnswerRe: How do I format the export of Formview data to Excel Pin
Member 109587799-Mar-15 17:34
Member 109587799-Mar-15 17:34 
QuestionMail Comes On My Interface Pin
Member 93756507-Mar-15 23:09
Member 93756507-Mar-15 23:09 
GeneralRe: Mail Comes On My Interface Pin
Kornfeld Eliyahu Peter8-Mar-15 0:01
professionalKornfeld Eliyahu Peter8-Mar-15 0:01 
AnswerRe: Mail Comes On My Interface Pin
Richard MacCutchan8-Mar-15 2:12
mveRichard MacCutchan8-Mar-15 2:12 
Question3D Image in asp.net webforms Pin
BISGroup6-Mar-15 1:40
BISGroup6-Mar-15 1:40 
AnswerRe: 3D Image in asp.net webforms PinPopular
F-ES Sitecore6-Mar-15 2:34
professionalF-ES Sitecore6-Mar-15 2:34 
GeneralRe: 3D Image in asp.net webforms Pin
Dave Kreskowiak6-Mar-15 13:14
mveDave Kreskowiak6-Mar-15 13:14 
QuestionManually Coding an Edit, Update, Cancel Button in Gridview Asp.net Pin
Robmyel Padrinao5-Mar-15 20:05
Robmyel Padrinao5-Mar-15 20:05 
AnswerRe: Manually Coding an Edit, Update, Cancel Button in Gridview Asp.net Pin
deepankarbhatnagar10-Mar-15 23:02
professionaldeepankarbhatnagar10-Mar-15 23:02 
QuestionHandling Active Links which redirect to another report in reports using Report Viewer Pin
Kandepu Rajesh4-Mar-15 11:17
Kandepu Rajesh4-Mar-15 11:17 
AnswerRe: Handling Active Links which redirect to another report in reports using Report Viewer Pin
Kandepu Rajesh5-Mar-15 5:26
Kandepu Rajesh5-Mar-15 5:26 
GeneralRe: Handling Active Links which redirect to another report in reports using Report Viewer Pin
Richard MacCutchan5-Mar-15 6:48
mveRichard MacCutchan5-Mar-15 6:48 
AnswerRe: Handling Active Links which redirect to another report in reports using Report Viewer Pin
jkirkerx5-Mar-15 7:47
professionaljkirkerx5-Mar-15 7:47 
GeneralRe: Handling Active Links which redirect to another report in reports using Report Viewer Pin
Kandepu Rajesh5-Mar-15 8:19
Kandepu Rajesh5-Mar-15 8:19 
GeneralRe: Handling Active Links which redirect to another report in reports using Report Viewer Pin
jkirkerx5-Mar-15 9:06
professionaljkirkerx5-Mar-15 9:06 
QuestionIs Office required to have installed on the machine with Interop dll? Pin
sudevsu3-Mar-15 7:56
sudevsu3-Mar-15 7:56 
AnswerRe: Is Office required to have installed on the machine with Interop dll? Pin
F-ES Sitecore3-Mar-15 8:06
professionalF-ES Sitecore3-Mar-15 8:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.