Getting HTML output generated by Datagrid in ASP.NET

A

Ajay Kumar

Hi everybody out there

i am developing a control in ASP.NET and would like to know that how to trap
the HTML content spitted by DataGrid Control.
I know that RenderControl traps the html output and browser renders it on
browser....
but i would like to trap that html code at server side in a string
variable....
hope to hear from the world soon

thanks in advance

Ajay Kumar
 
R

Rajagopal Pasupuleti

write a custom function that accepts a value from one or more of the
DataSource's fields as input and returns a string. This function would
then be called using the data-binding syntax:

<%# YourFunction(DataBinder.Eval(Container.DataItem,
"FieldName")) %>
 
D

Debasish Bose

Hi,
Create new custom control by deriving it from DataGrid. Override the
Render()
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)

'Catch all the rendered output of the base datagrid
Dim sWR As System.IO.StringWriter = New System.IO.StringWriter

'Create a HtmlTextWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(sWR)

'Catch the rendered HTML as string
MyBase.RenderControl(oHtmlTextWriter)

Dim sGridHtml As String = sWR.ToString()

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top