Geeks With Blogs


Agha Usman Ahmed JILAWATAN

In this post I will share with you a small code snippet which will help you to get the repeater control output in string variable.

   1: Dim sb As New StringBuilder()
   2: Dim objHtml As New HtmlTextWriter(New System.IO.StringWriter(sb))
   4: If dt.Rows.Count > 0 Then
   5:     Repeater1.DataSource = dt
   6:     Repeater1.DataBind()
   7: End If
   9: Repeater1.RenderControl(objHtml)
  10: Return sb.ToString() 


Well, I have used a little trick here. The RenderControl method of repeater control can put all the HTML in HtmlTextWriter Object and from HtmlTextWriter Object we have simply dump the output the to the string builder. That’s it ….

Posted on Monday, April 13, 2009 8:29 PM , | Back to top

Comments on this post: Get Repeater Control Output in String

# re: Get Repeater Control Output in String
Requesting Gravatar...
Many thanks! This is an awesome script, and contrary to all the errors posted, it works straight away.
Left by ipe hardwood decking on Jun 23, 2010 5:00 PM

Your comment:
 (will show your gravatar)

Copyright © Agha Usman Ahmed | Powered by: