简体   繁体   English

ASP.net ListView控件模板

[英]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. 我已经在Photoshop中设计了如下的样机设计,如下所示: http://i53.tinypic.com/1z5qdeq.jpg ,我打算将其“应用”到我的电子商务站点的ListView控件中。 I've been reading through documentations on templates for ListView but don't know where I should get started. 我一直在阅读ListView模板的文档,但是不知道应该从哪里开始。 The part that I would like to implement is the design itself (the box and 2 buttons) into my ListView control. 我要实现的部分是ListView控件中的设计本身(框和2个按钮)。

i hope this will do what you want simply; 我希望这会简单地完成您想要的;

  • on aspx page 在aspx页面上

对不起,不能在这里写代码 - on cs -在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. ListView允许您使用布局的自定义模板和可以通过编程方式创建的项目,但这对您来说是不必要的。 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. 让我知道情况是否如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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