Solved

How to retrieve content of a DataGrid control?

Posted on 2004-04-10
3
197 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
[X]
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
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to identify a paragraph in the body of text? 2 75
Updating a single record in forEach using C#/Entity 7 36
C# DataTable (in memory) vs SQL Lookups 4 67
c#, case, if 4 35
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 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