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
It is surprisingly simple...
Code behind:
// Here's your object that you'll create a list of
private class Products
{
public string ProductName { get; set; }
public string ProductDescription { get; set; }
public string ProductPrice { get; set; }
}
// Here you pass in the List of Products
private void BindItemsInCart(List ListOfSelectedProducts)
{
// The the LIST as the DataSource
this.rptItemsInCart.DataSource = ListOfSelectedProducts;
// Then bind the repeater
// The public properties become the columns of your repeater
this.rptItemsInCart.DataBind();
}
ASPX code:
Product Name
Product Description
Product Price
<%# Eval("ProductName") %>
<%# Eval("ProductDescription")%>
<%# Eval("ProductPrice")%>
I hope this helps!