The Repeater element is suitable for this. This allows you to bind to a data source and create a template for displaying elements.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %> ... <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <asp:CheckBox ID="checkBox" runat="server" /> <act:Gravatar runat="server" ID="gravatar" Email='<%# DataBinder.Eval(Container, "DataItem.useremail")%>' Size="50" Rating="G" DefaultImageBehavior="Identicon" DefaultImage="http://tinyurl.com/3bpsaac" /> <asp:Label ID="userName" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.username")%>'></asp:Label> <br /> </ItemTemplate> </asp:Repeater>
I have this Repeater associated with the following DataTable :
System.Data.DataTable GetRepeaterData() { DataTable dt = new DataTable(); dt.Columns.Add("username", typeof(string)); dt.Columns.Add("useremail", typeof(string)); dt.Rows.Add("user_one", " test@superexpert.com "); dt.Rows.Add("user_two", " test@superexpert.com "); dt.Rows.Add("user_three", " test@superexpert.com "); return dt; }
source share