473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Code to export html table (.RenderControl) doesn't like sort headings?

Hi again,

I have a datagrid which uses several fields such as:

<asp:BoundColumn DataField="DateEntered" HeaderText="Date Entered"
SortExpression="DateEntered"></asp:BoundColumn>

All works ok, until I put this code in the page to allow the user save
the html table as an excel file:

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition",
"attachment;filename=MyFileName.xls")
Response.Charset = ""
Me.EnableViewState = False

'get datagrid HTML from the control, write straight to browser
Dim objSW As New System.IO.StringWriter()
Dim objHTW As New System.Web.UI.HtmlTextWriter(objSW)
dg.RenderControl(objHTW)
Response.Write(objSW.ToString())
Response.End()

I get a global failure saying: System.Web.HttpException: Control
'dg__ctl1__ctl0' of type 'DataGridLinkButton' must be placed inside a
form tag with runat=server.

this control is the DateEntered sort column heading in the datagrid
(first control of the row).

Any clues, as always, greatly appreciated...this one is driving me a bit
nuts.

Thanks,

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #1
2 2500
"Kathy Burke" <ka**********@attbi.com> wrote in message
news:OW**************@TK2MSFTNGP09.phx.gbl...
Hi again, .... I get a global failure saying: System.Web.HttpException: Control
'dg__ctl1__ctl0' of type 'DataGridLinkButton' must be placed inside a
form tag with runat=server.


Kathy,

Is it possible that the exception message is telling you the truth?
--
John

Nov 17 '05 #2
Hmmm, John, it's hard to trust what a machine tells me! :-)

Anyhow, this code worked for my co-worker but then I realized he wasn't
using sort columns in the header. I ended up binding to the datasource
in the sub and then rendering. Works ok now.

Thanks,

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: A P | last post by:
Is this possible? I am planning to export data from SQL that generates HTML table. Instead of selecting the table and then copy then paste to word, I need a script(JS or VB) that will...
0
by: weiwei | last post by:
Hi, I have a table in View and I want to export that table into the excel sheet. I know that I can export file in Tables where there is a all task function, however, I cannt' find that function...
2
by: Jim Heavey | last post by:
I have an HTML table which has all kinds of special formatting and coloring and I am looking for how I should get this output to excel. I have an example working which is using the...
1
by: eldhopvm | last post by:
Hi I need an urgent help.I want the code for exporting an html table to Excel. The table is dynamically generated Html table only.Once the table is generated i want to export it to excel.(java...
5
by: =?Utf-8?B?c2NobWlkdGU=?= | last post by:
Hi How can I Export an HTML Table to excel? My goal is a button, and when the user clicks this button a popup appears asking the user to 'open' or 'save' the generated Excel file. Actually...
0
by: xlife | last post by:
I created HTML Table in code file, Now i want to export this table into PDF, Is it possible?
3
by: Shailesh Patel | last post by:
Hi, How do I export Html table to excel file? Thank you in advance. Shailesh
4
by: =?Utf-8?B?Q2FybGl0b3M=?= | last post by:
Hi there, I have a asp.net page that dynamically constructs a table based on data retrieved from a database. This is an excerpt of the code used: ' Create a row Dim row As HtmlTableRow = New...
6
by: gmujjain4902 | last post by:
Hi, Please help me with code for to Export HTML table to Excel sheet using javascript without using ActiveX controls... The problem is i could get solution for my problem via ActiveX control...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.