By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,487 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

Export Datagrid to text file for froogle feed

P: n/a
I have a page with a datagrid that I have configured with all the
information I need to provide to froogle for listing my products on
their site. I am having trouble finding a way to successfully save the
data in this datagrid as a text file.

I am somewhat limited in that I do _NOT_ have access to code-behind.
All code I use must be inline on the ASPX and the ASCX pages. I can
create new pages if that would help.

Does anyone know of a way to export the data using only inline code on
this page? The datagrid has an id="grdResults". The code does not need
to download the text file, just save it to a folder on the site. I can
download it later.

If any of you have solutions or suggestions I would be very grateful!
Thanks,
five40

Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
hi
although it can be easier to have code-behind, to my knowledge you can
achieve the same things with inline code. so don't worry about that.
this code below will render a datagrid into a string, which is a valid excel
document.

// get the text of the rendered datagrid
string datagridText;
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
// instantiate a datagrid
grdResults.RenderControl(htw);
datagridText = sw.ToString();
}
}

if you want a CSV format, you can adapt the code from this article:
http://tim.mackey.ie/PermaLink.aspx?...d-7e3ee82af55f
and instead of sending the CSV string to the HttpResponse, write it to a
file.

hope this helps
tim

--------------------------
blog: http://tim.mackey.ie

<fo**********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I have a page with a datagrid that I have configured with all the
information I need to provide to froogle for listing my products on
their site. I am having trouble finding a way to successfully save the
data in this datagrid as a text file.

I am somewhat limited in that I do _NOT_ have access to code-behind.
All code I use must be inline on the ASPX and the ASCX pages. I can
create new pages if that would help.

Does anyone know of a way to export the data using only inline code on
this page? The datagrid has an id="grdResults". The code does not need
to download the text file, just save it to a folder on the site. I can
download it later.

If any of you have solutions or suggestions I would be very grateful!
Thanks,
five40

Nov 19 '05 #2

P: n/a
I've listed the steps to export a datagrid to Excel here:
http://SteveOrr.net/Articles/ExcelExport.aspx
It also includes other exporting techniques.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
<fo**********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I have a page with a datagrid that I have configured with all the
information I need to provide to froogle for listing my products on
their site. I am having trouble finding a way to successfully save the
data in this datagrid as a text file.

I am somewhat limited in that I do _NOT_ have access to code-behind.
All code I use must be inline on the ASPX and the ASCX pages. I can
create new pages if that would help.

Does anyone know of a way to export the data using only inline code on
this page? The datagrid has an id="grdResults". The code does not need
to download the text file, just save it to a folder on the site. I can
download it later.

If any of you have solutions or suggestions I would be very grateful!
Thanks,
five40

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.