Dear All,
I want to export datagrid content to a Excel file, the code just like below:
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
gridList.Columns(0).Visible = False
gridList.Columns(1).SortExpression = ""
gridList.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
....
If my datagrid Allowsorting=true, then the code run error,but if I config the Allowsorting=false, then above code run fine.
Please help me how to export if my datagrid has the allowsorting properity.
Any help welcomes.
Best Regards,
Eric. 6 5771
In this instance, since you know what the user wants when you query the
data, I would consider sorting the data on the server when you pull the
data. I am not sure why it bombs (I would have to examine the HTML
produced), but it is easily solved by sorting on the Data tier and avoiding
the issue on the Presentation tier.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge
************************************************** **************************
****
Think Outside the Box!
************************************************** **************************
****
"Eric" <Er******@hotmail.com> wrote in message
news:uE**************@TK2MSFTNGP10.phx.gbl...
Dear All,
I want to export datagrid content to a Excel file, the code just like
below:
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
gridList.Columns(0).Visible = False
gridList.Columns(1).SortExpression = ""
gridList.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
....
If my datagrid Allowsorting=true, then the code run error,but if I
config the Allowsorting=false, then above code run fine.
Please help me how to export if my datagrid has the allowsorting
properity.
Any help welcomes.
Best Regards,
Eric.
what he said, sort on the data layer
"Cowboy (Gregory A. Beamer)" <No************@comcast.netRemuvThis> wrote in
message news:Od*************@TK2MSFTNGP11.phx.gbl... In this instance, since you know what the user wants when you query the data, I would consider sorting the data on the server when you pull the data. I am not sure why it bombs (I would have to examine the HTML produced), but it is easily solved by sorting on the Data tier and
avoiding the issue on the Presentation tier.
-- Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA Author: ADO.NET and XML: ASP.NET on the Edge
************************************************** ************************** **** Think Outside the Box!
************************************************** ************************** **** "Eric" <Er******@hotmail.com> wrote in message news:uE**************@TK2MSFTNGP10.phx.gbl... Dear All,
I want to export datagrid content to a Excel file, the code just like below:
Response.ContentType = "application/vnd.ms-excel" Response.Charset = "" Me.EnableViewState = False Dim tw As New System.IO.StringWriter() Dim hw As New System.Web.UI.HtmlTextWriter(tw) gridList.Columns(0).Visible = False gridList.Columns(1).SortExpression = "" gridList.RenderControl(hw) Response.Write(tw.ToString()) Response.End()
...
If my datagrid Allowsorting=true, then the code run error,but if I config the Allowsorting=false, then above code run fine. Please help me how to export if my datagrid has the allowsorting properity.
Any help welcomes.
Best Regards, Eric.
Would you like to tell me how to do?
Thanks.
"Cowboy (Gregory A. Beamer)" <No************@comcast.netRemuvThis> дÈëÏûÏ¢
ÐÂÎÅ:Od*************@TK2MSFTNGP11.phx.gbl... In this instance, since you know what the user wants when you query the data, I would consider sorting the data on the server when you pull the data. I am not sure why it bombs (I would have to examine the HTML produced), but it is easily solved by sorting on the Data tier and
avoiding the issue on the Presentation tier.
-- Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA Author: ADO.NET and XML: ASP.NET on the Edge
************************************************** ************************** **** Think Outside the Box!
************************************************** ************************** **** "Eric" <Er******@hotmail.com> wrote in message news:uE**************@TK2MSFTNGP10.phx.gbl... Dear All,
I want to export datagrid content to a Excel file, the code just like below:
Response.ContentType = "application/vnd.ms-excel" Response.Charset = "" Me.EnableViewState = False Dim tw As New System.IO.StringWriter() Dim hw As New System.Web.UI.HtmlTextWriter(tw) gridList.Columns(0).Visible = False gridList.Columns(1).SortExpression = "" gridList.RenderControl(hw) Response.Write(tw.ToString()) Response.End()
...
If my datagrid Allowsorting=true, then the code run error,but if I config the Allowsorting=false, then above code run fine. Please help me how to export if my datagrid has the allowsorting properity.
Any help welcomes.
Best Regards, Eric.
He can probably tell you how to set your clock...
Here's how... Go to the first message that you post dated. Then from the
Message menu in OE, choose Block Sender.
"Eric" <Er******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... Would you like to tell me how to do? Thanks.
"Cowboy (Gregory A. Beamer)" <No************@comcast.netRemuvThis>
дÈëÏûÏ¢ ÐÂÎÅ:Od*************@TK2MSFTNGP11.phx.gbl... In this instance, since you know what the user wants when you query the data, I would consider sorting the data on the server when you pull the data. I am not sure why it bombs (I would have to examine the HTML produced), but it is easily solved by sorting on the Data tier and avoiding the issue on the Presentation tier.
-- Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA Author: ADO.NET and XML: ASP.NET on the Edge
************************************************** ************************** **** Think Outside the Box!
************************************************** ************************** **** "Eric" <Er******@hotmail.com> wrote in message news:uE**************@TK2MSFTNGP10.phx.gbl... Dear All,
I want to export datagrid content to a Excel file, the code just
like below:
Response.ContentType = "application/vnd.ms-excel" Response.Charset = "" Me.EnableViewState = False Dim tw As New System.IO.StringWriter() Dim hw As New System.Web.UI.HtmlTextWriter(tw) gridList.Columns(0).Visible = False gridList.Columns(1).SortExpression = "" gridList.RenderControl(hw) Response.Write(tw.ToString()) Response.End()
...
If my datagrid Allowsorting=true, then the code run error,but if I config the Allowsorting=false, then above code run fine. Please help me how to export if my datagrid has the allowsorting properity.
Any help welcomes.
Best Regards, Eric.
hi eric,
are you getting some error like 'link item must be placed into form tag with an attribute runat=server" if so then your problem is because of when you use htmltextwriter and render control into it where your grids sorting property set to true then link items generate this error because your htmltextwriter doesn't include form tag.try including some form tag into htmltextwriter or , first disable allowsorting property to false , then export to excel and then rebind your dataset with allowsorting set to true (also this has some side effects where grid losts page numbers. etc)
regards,
ersin gen?t¨¹rk
"Eric" <Er******@hotmail.com> wrote in message news:uE**************@TK2MSFTNGP10.phx.gbl...
Dear All,
I want to export datagrid content to a Excel file, the code just like below:
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
gridList.Columns(0).Visible = False
gridList.Columns(1).SortExpression = ""
gridList.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
...
If my datagrid Allowsorting=true, then the code run error,but if I config the Allowsorting=false, then above code run fine.
Please help me how to export if my datagrid has the allowsorting properity.
Any help welcomes.
Best Regards,
Eric. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bidarkota |
last post by:
When i export DataGrid to Excel all the HTML contents are also exporting to
excel. i am using stylesheets in the ASPX Page and i am getting an alert
message that stylesheets are missing. i need to...
|
by: Ed Chiu |
last post by:
Hi,
I copied the following codes from Internet to export datagrid to Excel, it
works with datagrid not supporting sorting or paging.
Response.ContentType = "application/vnd.ms-excel"...
|
by: jhgonzales |
last post by:
The datagrid is exporting but without the images. When the file is
downloaded, it seems that the excel file was supposed to have the images
because they appear as "broken" image in the file.
...
|
by: The Colonel |
last post by:
I'm only getting current page. I've tried playing with the
PageSize and AllowPaging = False before exporting, but no luck. Here's
my code:
<snip>
Public Sub btnExport_OnClick(ByVal sender...
|
by: chreo |
last post by:
I would like to export earnigs of employees from datagrid to EXCEL.
for example:
__________________________
|..name.............|..money...............|
-----------------------------------...
|
by: Sridhar |
last post by:
Hi,
I have to export data inside the datagrid into an excel worksheet. I have
to do this on button click event. I am trying to do like this.
First get the DataTable from the datagrid and...
|
by: Mike |
last post by:
Hello,
I am attempting to export the contents of a datagrid on my webform (using
Excel automation) through ASP.NET.
I have added the Excel object library to my VS ASP.NET project but I am...
|
by: madhavit |
last post by:
hi,
i am able to export datagrid data to excel sheet but the problem is i am not able to export datagrid within datagrid data to excel.
can anybody help me.
thanx.
|
by: leena13 |
last post by:
Hi,
The number of rows in the datagrid on my page are approx. around 14130. When I click on the button that exports the records to excel sheet, the page goes blank (I observed that none of the...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
header("Location:".$urlback);
Is this the right layout the...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
| |