Agha Usman

Lives in Karachi (Pakistan) and work for Ciber Strategies

Get Repeater Control Output in String

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))
   3:  
   4: If dt.Rows.Count > 0 Then
   5:     Repeater1.DataSource = dt
   6:     Repeater1.DataBind()
   7: End If
   8:  
   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: Apr 13 2009, 09:30 PM by aghausman12 | with 1 comment(s)
Filed under: ,

Comments

Get Repeater Control Output in String - Agha Usman said:

Pingback from  Get Repeater Control Output in String - Agha Usman

# April 13, 2009 11:48 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)