Code
// From msdn
<% @ Page Language = " C # " %>
<! Doctype HTML public " -// W3C // dtd xhtml 1.0 transitional // en "
" Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< Html >
< Head ID = " Head1 " Runat = " Server " >
< Title > ASP. NET repeater example </ Title >
</ Head >
< Body >
< Form ID = " Form1 " Runat = " Server " >
< Div >
< ASP: repeater ID = " Repeater1 " Runat = " Server " Performanceid = " Sqldatasource1 " >
< Headertemplate >
< Table >
< Tr >
< Th >
Name </ Th >
< Th >
Description </ Th >
</ Tr >
</ Headertemplate >
< Itemtemplate >
< Tr >
< TD Style = " Background-color: # ccffcc " >
< ASP: Label runat = " Server " ID = " Label1 " Text = ' <% # Eval ("categoryname") %> ' />
</ TD >
< TD Style = " Background-color: # ccffcc " >
< ASP: Label runat = " Server " ID = " Label2 " Text = ' <% # Eval ("Description") %> ' />
</ TD >
</ Tr >
</ Itemtemplate >
< Alternatingitemtemplate >
< Tr >
< TD >
< ASP: Label runat = " Server " ID = " Label3 " Text = ' <% # Eval ("categoryname") %> ' />
</ TD >
< TD >
< ASP: Label runat = " Server " ID = " Label4 " Text = ' <% # Eval ("Description") %> ' />
</ TD >
</ Tr >
</ Alternatingitemtemplate >
< Footertemplate >
</ Table >
</ Footertemplate >
</ ASP: Repeater >
< ASP: sqldatasource connectionstring = " <% $ Connectionstrings: northwindconnectionstring %> "
ID = " Sqldatasource1 " Runat = " Server " Selectcommand = " Select [categoryid], [categoryname],
[Description] from [categories] " > </ASP: sqldatasource>
</ Div >
</ Form >
</ Body >
</ Html >