ASP.net ListView Control Template
I have designed a mockup design in Photoshop as follows h开发者_JS百科ttp://i53.tinypic.com/1z5qdeq.jpg and I intend to "apply" it into my e-commerce site's ListView control. I've been reading through documentations on templates for ListView but don't know where I should get started. The part that I would like to implement is the design itself (the box and 2 buttons) into my ListView control.
i hope this will do what you want simply;
- on aspx page
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<Item> list = new List<Item>();
list.Add(new Item() { ImageURL = "~/sample.jpg", Title = "samsung galaxy" });
list.Add(new Item() { ImageURL = "~/sample.jpg", Title = "ipad" });
list.Add(new Item() { ImageURL = "~/sample.jpg", Title = "xoom" });
ListView1.DataSource = list;
ListView1.DataBind();
}
}
public class Item
{
public string ImageURL { get; set; }
public string Title { get; set; }
}
I don't think you need to create templates. ListView allows you to have custom templates for layout and items that you can create programmatically but thats unnecessary for this. I'm assuming you have a repeating model of products that you show in the sample. Just use a regular list view as follows.
I would explain it all over again here but I think this link explains exactly what you need to. Let me know if thats not the case.
精彩评论