简体   繁体   中英

ASP.net ListView Control Template

I have designed a mockup design in Photoshop as follows http://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

对不起,不能在这里写代码 - on cs

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM