c# - ListView 控件

标签 c# .net asp.net css listview

我在 Photoshop 中设计了一个模型,我打算将它应用到我的产品目录的 ListView 控件中,但它似乎没有正确显示(未对齐?),我希望这里的人可以像我一样指出我的错误试图弄清楚无济于事。

预期结果/模型: Expected result/Mockup

调试后(不要介意丢失的照片): enter image description here

看看我的代码,

CSS:

.productItem {
     width: 200px;
     float: left;
     padding: 5px;
     margin: 5px;
     text-align: center;
     background-color: White;        
}
.cell1 
{
     width:117px;
     height:27px;
     background-image: url("images/blackbutton.jpg");
     float:left;
     font-size:12px;
     vertical-align:middle;
     color:White;
     text-align:center;
}
.cell2 
{
     width:118px;
     height:27px;
     background-image: url("images/orangebutton.jpg");
     float:left;
     font-size:12px;
     vertical-align:middle;
     color:White;
     text-align:center;
}

ListView 说明:

<div class="catalog">
    <asp:ListView runat="server" ID="listView" GroupItemCount="3" DataSourceID="AccessDataSource1">
        <LayoutTemplate>
            <div style="height: 962px;">
            <div style="width: 790px;">
                <asp:PlaceHolder runat="server" ID="groupPlaceHolder" />
                <asp:DataPager runat="server" ID="dpMyDatePager" PageSize="3" PagedControlID="listView" .Ю
            </div>
        </LayoutTemplate>
        <GroupTemplate>
            <div style="clear: both;">
                <asp:PlaceHolder runat="server" ID="itemPlaceHolder" />
            </div>
        </GroupTemplate>
        <ItemTemplate>
            <div class="productItem">
            <div>
                <img src='<%# Eval("ProductUrl") %>' height="180" width="200" />
            </div>
            <div>
                <b>
                   <%# Eval("ProductBrand") %> <%# Eval("ProductModel") %></b>
            </div>
            <div>
                Our Price: $<%# Eval("NormalPrice") %>
            </div>
        </div>
        <div class="cell1">Add to cart</div>
        <div class="cell2">View details</div>
    </ItemTemplate>
    </asp:ListView>
</div>

最佳答案

将单元格 1 和单元格 2 的宽度更改为 50% 并尝试以下布局:

<LayoutTemplate>
    <div style="height: 962px;">
        <div style="width: 790px;">
            <asp:PlaceHolder runat="server" ID="groupPlaceHolder" />
        </div>
        <asp:DataPager runat="server" ID="dpMyDatePager" PageSize="6" PagedControlID="listView"></asp:DataPager>
    </div>
</LayoutTemplate>
<GroupTemplate>
    <div style="clear: both;">
        <asp:PlaceHolder runat="server" ID="itemPlaceHolder" />
    </div>
</GroupTemplate>
<ItemTemplate>
    <div class="productItem">
        <div>
            <img src='<%# Eval("ProductUrl") %>' height="180" width="200" />
        </div>
        <div>
            <b>
                <%# Eval("ProductBrand") %>
                <%# Eval("ProductModel") %></b></div>
        <div style="clear: right;">
            Our Price: $<%# Eval("NormalPrice") %></div>
        <div class="cell1">
            Add to cart</div>
        <div class="cell2">
            View details</div>
    </div>
</ItemTemplate>

关于c# - ListView 控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6814011/

相关文章:

asp.net - 使用 DataSet 将 RadComboBox 绑定(bind)到 ObjectDataSource

c# - 为什么要尝试使用字符串? C# 中的(可空字符串)产生语法错误?

c# - EF LINQ 查询 if 子句中抛出空引用异常

c# - 如何调用无参方法?

c# - ReactiveUI命令退订

asp.net - Assembly.GetExecutingAssembly() 性能

c# - Silverlight:为图像添加透明度

c# - 如何全局告诉 Json.Net 将 StringEnumConverter 应用于所有枚举

c# - Lutz Roeder 的 HTML Writer 在 SaveHtml() 方法中只返回 2 个字符

c# - 在类库中包含 View