Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to retrieve content of a DataGrid control?

Posted on 2004-04-10
3
195 Views
Last Modified: 2010-04-15
I have a DataGrid control that I is formated and displayed as a table in HTML.
How do I retrieve the formatted html (i.e. end result of displaying DataGrid) from the DataGrid control?

More specifically, I am using the DataGrid in a UserControl - thus, is there a way of retrieving the formatted output of the DataGrid.

Cheers.
0
Comment
Question by:smacca
  • 2
3 Comments
 

Author Comment

by:smacca
ID: 10799869
THOUGHTS OUT ALOUD:

  * Perhaps I could place within a container that has a Text property?? Does the Panel control do this or any other?
 
0
 

Author Comment

by:smacca
ID: 10800210
SOLUTION:
----------------


public string GetContent()
{
      //get the rendered HTML
      StringBuilder sb = new StringBuilder();  
      StringWriter sw = new StringWriter(sb);
      HtmlTextWriter htw = new HtmlTextWriter(sw);
      dgRecordDataGrid.RenderControl(htw);                
      return Server.HtmlEncode(sb.ToString());
}
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 10801674
Closed, 400 points refunded.
modulo
Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question