Solved

How to retrieve content of a DataGrid control?

Posted on 2004-04-10
3
194 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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