Problem with controls collection exporting data
-
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.
-
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.
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.
-
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.
-
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.
-
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.
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.
-
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.
-
I thought So..! :-\
LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.
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.
-
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.
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 -
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 JavascriptAbhishek 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"
-
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"
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