[英]Adding row to Datalist
I have been searching around the web for a solution to this issue but have come across nothing so far. 我一直在网上搜索该问题的解决方案,但到目前为止没有发现任何问题。
Basically I have a table as shown below, which I made up of ItemTemplate
fields and is populated by a DataSet from my database. 基本上,我有一个表,如下所示,该表由
ItemTemplate
字段组成,并由数据库中的DataSet填充。 It shows brands to the user of which they can then click and go onto another page. 它向用户显示品牌,然后他们可以单击品牌并转到另一个页面。
I need to add another option to the table called "All Brands". 我需要在表中添加另一个选项“所有品牌”。 Thus then I can use this to go to a page showing all the brands.
因此,我可以使用它转到显示所有品牌的页面。 However I can not seem to easily add this into the DataList.
但是,我似乎无法轻松地将此添加到DataList中。
<asp:DataList id="TypesList" runat="server" Visible="true" RepeatColumns="3" Width="100%" ItemStyle-Width="25%" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<div style="position:relative;vertical-align:top;">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="center" style="height:170px;vertical-align:top;text-align:center;" valign="top">
<asp:Label ID="lblID" runat="server" Visible="false" Text='<%#DataBinder.Eval(Container.DataItem,"batteryTypeID")%>'></asp:Label>
<a href='/<%#DataBinder.Eval(Container.DataItem,"catid")%>/<%#DataBinder.Eval(Container.DataItem,"catname")%>/<%#DataBinder.Eval(Container.DataItem,"brandid")%>/<%#DataBinder.Eval(Container.DataItem,"brand_name")%>/<%#DataBinder.Eval(Container.DataItem,"batteryTypeID")%>/<%#DataBinder.Eval(Container.DataItem,"typeName")%>' target='_self'>
<asp:Image ID="imgProd" runat="server" ImageUrl='images/none.jpg' />
</a>
</td>
</tr>
<tr>
<td class="productdesc" style="text-align:center;vertical-align:top;">
<span style="color:#000;font-weight:bold;font-size:120%;">
<%#DataBinder.Eval(Container.DataItem, "typeName").ToString%>
</span>
</td>
</tr>
</table>
</div>
</ItemTemplate>
</asp:DataList>
You should be able to solve this with the following layout: 您应该可以使用以下布局解决此问题:
<asp:DataList id="TypesList" runat="server" Visible="true" RepeatColumns="3" Width="100%" ItemStyle-Width="25%" ItemStyle-HorizontalAlign="Center">
<HeaderTemplate>
<div style="width:170px; float:left;">
<div>All Brands Pic and Link</div>
<div>
<span style="color:#000;font-weight:bold;font-size:120%;">All Brands</span>
</div>
</div>
</HeaderTemplate>
<ItemTemplate>
<div style="width:170px; float:left;">
<div>
<asp:Label ID="lblID" runat="server" Visible="false" Text='<%#DataBinder.Eval(Container.DataItem,"batteryTypeID")%>'></asp:Label>
<a href='/<%#DataBinder.Eval(Container.DataItem,"catid")%>/<%#DataBinder.Eval(Container.DataItem,"catname")%>/<%#DataBinder.Eval(Container.DataItem,"brandid")%>/<%#DataBinder.Eval(Container.DataItem,"brand_name")%>/<%#DataBinder.Eval(Container.DataItem,"batteryTypeID")%>/<%#DataBinder.Eval(Container.DataItem,"typeName")%>' target='_self'>
<asp:Image ID="imgProd" runat="server" ImageUrl='images/none.jpg' />
</a>
</div>
<div>
<span style="color:#000;font-weight:bold;font-size:120%;">
<%#DataBinder.Eval(Container.DataItem, "typeName").ToString%>
</span>
</div>
</div>
</ItemTemplate>
</asp:DataList>
My css is a little rusty but I trust people will be happy to point out how it could be styled better. 我的CSS有点生锈,但是我相信人们会很乐意指出如何更好地设计样式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.