Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem with controls collection exporting data

Problem with controls collection exporting data

Scheduled Pinned Locked Moved ASP.NET
helpquestion
10 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Maxdd 7
    wrote on last edited by
    #1

    I have a GridView where I can export to excel file. In the beginning of the page where gridview is, I have the following:

    <b>Bem vindo <% Response.Write(Session["nome"].ToString()); %>!</b>

    Now I've tested the export funcionality again, and having the following error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). I googled about it, and looks like because Response.write does not allow the export encoding operation perform correctly, so I commented that line, and now its working again. So I'm wondering, I really want to use that line. How do I do it? Is it possible? Many thanks.

    C S A 3 Replies Last reply
    0
    • M Maxdd 7

      I have a GridView where I can export to excel file. In the beginning of the page where gridview is, I have the following:

      <b>Bem vindo <% Response.Write(Session["nome"].ToString()); %>!</b>

      Now I've tested the export funcionality again, and having the following error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). I googled about it, and looks like because Response.write does not allow the export encoding operation perform correctly, so I commented that line, and now its working again. So I'm wondering, I really want to use that line. How do I do it? Is it possible? Many thanks.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Response.Write is idiocy in this context. Just remove it.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      M 1 Reply Last reply
      0
      • C Christian Graus

        Response.Write is idiocy in this context. Just remove it.

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        M Offline
        M Offline
        Maxdd 7
        wrote on last edited by
        #3

        Christian Graus wrote:

        Response.Write is idiocy in this context. Just remove it.

        I havent asked you if its idiocy or not. I asked you if there is a alternative or solution.

        1 Reply Last reply
        0
        • M Maxdd 7

          I have a GridView where I can export to excel file. In the beginning of the page where gridview is, I have the following:

          <b>Bem vindo <% Response.Write(Session["nome"].ToString()); %>!</b>

          Now I've tested the export funcionality again, and having the following error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). I googled about it, and looks like because Response.write does not allow the export encoding operation perform correctly, so I commented that line, and now its working again. So I'm wondering, I really want to use that line. How do I do it? Is it possible? Many thanks.

          S Offline
          S Offline
          sashidhar
          wrote on last edited by
          #4

          Maxdd 7 wrote:

          Bem vindo <% Response.Write(Session["nome"].ToString()); %>!

          whats tht '!'

          LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

          A 1 Reply Last reply
          0
          • S sashidhar

            Maxdd 7 wrote:

            Bem vindo <% Response.Write(Session["nome"].ToString()); %>!

            whats tht '!'

            LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

            A Offline
            A Offline
            Abhijit Jana
            wrote on last edited by
            #5

            That's why he is getting the error !

            Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

            S 1 Reply Last reply
            0
            • A Abhijit Jana

              That's why he is getting the error !

              Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

              S Offline
              S Offline
              sashidhar
              wrote on last edited by
              #6

              I thought So..! :-\

              LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

              A 1 Reply Last reply
              0
              • S sashidhar

                I thought So..! :-\

                LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

                A Offline
                A Offline
                Abhijit Jana
                wrote on last edited by
                #7

                Solution has already provided by CG, but he is not interested with that solution. :zzz:

                Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

                1 Reply Last reply
                0
                • M Maxdd 7

                  I have a GridView where I can export to excel file. In the beginning of the page where gridview is, I have the following:

                  <b>Bem vindo <% Response.Write(Session["nome"].ToString()); %>!</b>

                  Now I've tested the export funcionality again, and having the following error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). I googled about it, and looks like because Response.write does not allow the export encoding operation perform correctly, so I commented that line, and now its working again. So I'm wondering, I really want to use that line. How do I do it? Is it possible? Many thanks.

                  A Offline
                  A Offline
                  Abhishek Sur
                  wrote on last edited by
                  #8

                  Use <% =Session["nome"] as string %> instead of <% Response.Write(Session["nome"].ToString()); %>. As Response is implicit here for the Designer, you cant access it directly. ;)

                  Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                  My Latest Articles-->** Simplify Code Using NDepend
                  Basics of Bing Search API using .NET
                  Microsoft Bing MAP using Javascript

                  M 1 Reply Last reply
                  0
                  • A Abhishek Sur

                    Use <% =Session["nome"] as string %> instead of <% Response.Write(Session["nome"].ToString()); %>. As Response is implicit here for the Designer, you cant access it directly. ;)

                    Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                    My Latest Articles-->** Simplify Code Using NDepend
                    Basics of Bing Search API using .NET
                    Microsoft Bing MAP using Javascript

                    M Offline
                    M Offline
                    Maxdd 7
                    wrote on last edited by
                    #9

                    Abhishek Sur wrote:

                    <% =Session["nome"] as string %> instead of <% Response.Write(Session["nome"].ToString()); %>.

                    That way gives the same error. Maybe you are all right, I really should remove that. I was trying do that because I had a problem using LoginView:

                    <asp:LoginView id="logview" runat="server">
                    <LoggedInTemplate>
                    Welcome <asp:LoginName id="txtUserName" runat="server"/>

                    </LoggedInTemplate>

                    </asp:LoginView>

                    The problem is: since the login name is email ID, (and the name of the user is another field in DB), it appears something like "Welcome tmm@yahoo.com"

                    A 1 Reply Last reply
                    0
                    • M Maxdd 7

                      Abhishek Sur wrote:

                      <% =Session["nome"] as string %> instead of <% Response.Write(Session["nome"].ToString()); %>.

                      That way gives the same error. Maybe you are all right, I really should remove that. I was trying do that because I had a problem using LoginView:

                      <asp:LoginView id="logview" runat="server">
                      <LoggedInTemplate>
                      Welcome <asp:LoginName id="txtUserName" runat="server"/>

                      </LoggedInTemplate>

                      </asp:LoginView>

                      The problem is: since the login name is email ID, (and the name of the user is another field in DB), it appears something like "Welcome tmm@yahoo.com"

                      A Offline
                      A Offline
                      Abhishek Sur
                      wrote on last edited by
                      #10

                      Yeah... I think this solves the problem. Other than that you can store the Displayname in a protected variable in server side and use <%=yourvariable%> also. :rose:

                      Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                      My Latest Articles-->** Simplify Code Using NDepend
                      Basics of Bing Search API using .NET
                      Microsoft Bing MAP using Javascript

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups