Valid XHTML Dynamic List Instead Of Using A Repeater

30. January 2009

Repeater controls are great for displaying lists. But these the lists displayed are not valid XHTML. To make sure my pages are valid I have had to use a workaround.

For my events list I created a shared function, in case I need to reuse it.

Public Shared Function getOrderedEventsList (ByVal ds As DataSet) As String
'take dataset and return an ordered list string that is valid XHTML
Dim strResult As String = String.Empty
strResult += "<ol>"
Dim dr As DataRow
For Each dr In ds.Tables(0).Rows
strResult += "<li>" & dr("EventTitle") & "</li>"
Next
strResult += "</ol>"
Return strResult
End Function

Using an empty div and from the code behind I am filling it using InnerHtml.

divName.InnerHtml = getOrderedEventsList(dataset)

You can use this for any dynamic list instead of a repeater. And your code will be valid XHTML.

.Net ,

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading





Marketing & SEO Blogs - Blog Top SitesBlog Flux Directory Marketing / SEO Top Blogs Internet Marketing & SEO (Link Building) - TOP.ORG Add to Technorati Favorites TopOfBlogs