I have a repeater with which I want to use to show a user control multiple times, populated with data.
Currently, I have this:
<asp:Repeater runat="server" ID="MyRepeater" >
<ItemTemplate>
<uc1:MyItems ID="MyItems1" runat="server" />
</ItemTemplate>
</asp:Repeater>
My user control has three properties, which I want to populate for each. I currently have this:
protected void Page_Load(object sender, EventArgs e)
{
MyDataSource.SelectCommand =
"SELECT Name, Address, Phone " +
"FROM TestTable ";
MyDataSource.SelectCommandType = SqlDataSourceCommandType.Text;
DataView resultsdv = (DataView)MyDataSource.Select(DataSourceSelectArguments.Empty);
foreach (DataRow dr in resultsdv.Table.Rows)
{
MyItems1.Cust_Name = dr["Name"].ToString();
MyItems1.Cust_Address = dr["Address"].ToString();
MyItems1.Cust_Tel = dr["Phone"].ToString();
}
}
Obviously, this isn’t doing what I want. Is it possible to tell the repeater that I want to populate my user control – either by data binding it, or manually populate it in a way similar to above?