Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Export datagrid(with allowsorting) to Excel

Reply
Thread Tools

Export datagrid(with allowsorting) to Excel

 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      06-25-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
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.


 
Reply With Quote
 
 
 
 
George Durzi
Guest
Posts: n/a
 
      06-25-2003
what he said, sort on the data layer

"Cowboy (Gregory A. Beamer)" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> 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.
>
>



 
Reply With Quote
 
 
 
 
CJM
Guest
Posts: n/a
 
      06-26-2003
He can probably tell you how to set your clock...


 
Reply With Quote
 
Alex B
Guest
Posts: n/a
 
      06-26-2003
Here's how... Go to the first message that you post dated. Then from the
Message menu in OE, choose Block Sender.

"Eric" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Would you like to tell me how to do?
> Thanks.
>
> "Cowboy (Gregory A. Beamer)" <(E-Mail Removed)>

写入消息
> 新闻:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > 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.
> >
> >

>
>



 
Reply With Quote
 
=?gb2312?B?RXJzaW4gR2VuP3SouXJr?=
Guest
Posts: n/a
 
      06-27-2003
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
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.


 
Reply With Quote
 
Eric
Guest
Posts: n/a
 
      07-03-2003
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.


 
Reply With Quote
 
Eric
Guest
Posts: n/a
 
      07-04-2003
Would you like to tell me how to do?
Thanks.

"Cowboy (Gregory A. Beamer)" <(E-Mail Removed)> 写入消息
新闻:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> 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.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export to Excel (Default File Type - Excel) =?Utf-8?B?SGVtYW50IFNpcGFoaW1hbGFuaQ==?= ASP .Net 15 05-21-2009 12:01 PM
Problem with Excel reports ::::Excel 2003 Migration To Excel 2007 =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?= ASP .Net 15 10-24-2007 01:34 PM
Export to excel in asp.net using excel template Grey ASP .Net 4 10-17-2007 08:08 AM
using Microsoft Excel image for Export to Excel button =?Utf-8?B?U3JpZGhhcg==?= ASP .Net 0 12-09-2005 08:58 PM
Invalid export DLL or export format =?Utf-8?B?RGF2aWQgVmFsbGU=?= ASP .Net 0 10-29-2003 11:46 AM



Advertisments