Lesser Known ASP.NET Repeater Control Tips

ASP.NET Repeater control is a lightweight data-bound list control which lets you customize your layout by repeating a specified template. This article will show the three lesser known ASP.NET Control tips.

Do you know that:

You can bind ASP.NET Repeater to List <string>
Just declare a List<string> then let it exposed to a get/set property . This will allow you to consume this List<> using LINQDataSource.

You can access checkbox inside a repeater programmatically
To do that, just use the code in the rptName_ItemDataBound() event. In this code below, we are assuming that the married property is bound to the checkbox:

foreach (RepeaterItem item in rptName.Items)
{
CheckBox cb = item.FindControl(“chkbox”) as CheckBox;
if (cb.Checked)
{
Response.Write(“Status: ” + cb.Attributes[“married”].ToString() + “< br />”);
}
}

Read the rest of the article here: http://www.devcurry.com/2013/02/3-aspnet-repeater-control-tips.html

Leave a Reply

Your email address will not be published. Required fields are marked *