I am trying to bind a List
to a repeater. I have converted the list into an array by using the ToArray()
method and now have a arr
Code Behind:
public class Friends
{
public string ID { get; set; }
public string Name { get; set; }
public string Image { get; set; }
}
protected void Page_Load(object sender, EventArgs e)
{
List friendsList = new List();
foreach (var friend in friendz)
{
friendsList.Add(
new Friends { ID = friend.id, Name = friend.name }
);
}
this.rptFriends.DataSource = friendsList;
this.rptFriends.DataBind();
}
.aspx Page
ID
Name
<%# Eval("ID") %>
<%# Eval("Name") %>