将div标签放置在listview控制器中的特定行 [英] place a div tag at a particular row in listview controller
本文介绍了将div标签放置在listview控制器中的特定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好..
我有listview控件,如:
hi all..
i have listview control like:
<asp:ListView ID="lst" runat="server" EnableModelValidation="True" GroupItemCount="3" >
<LayoutTemplate>
<table cellpadding="2" runat="server" id="tblProducts" style="height: 320px">
<tr runat="server" id="groupPlaceholder">
</tr>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr runat="server" id="productRow" style="height: 80px">
<td runat="server" id="itemPlaceholder">
</td>
</tr>
</GroupTemplate>
<ItemTemplate>
<td id="Td1" valign="top" align="center" style="padding-left: 14px;margin:0px;" runat="server">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<div class="box1">
<h2 style="text-align: left;">
Keywords:
<%# Eval("Keywords")%><br />
Phone:
<%# Eval("Contactno")%>
</h2>
<div class="contact">
<asp:Button ID="btncontact" runat="server" Text="More.." CommandArgument='<%# Eval("uid") %>' />
</div>
<div style="clear: both">
</div>
</div>
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td colspan="3" align="center" style="text-align: center;">
<center>
<%# (Container.DataItemIndex != 0 && (Container.DataItemIndex+1) % 6 == 0) ? @" <div id='divadd' style='height: 60px; width: 444px; border: solid 1px #ccc;font-weight:bold;vertical-align:middle;padding-removed35px;font-size:28px;'> Add Here Inserted Here</div>" : string.Empty %>
</center>
</td>
</tr>
</table>
</td>
</ItemTemplate>
</asp:ListView>
and pager
<asp:DataPager runat="server" ID="DataPager" PageSize="12" PagedControlID="lst" OnPreRender="DataPager_PreRender">
<Fields>
<asp:NumericPagerField ButtonCount="3" PreviousPageText="prev" NumericButtonCssClass="numeric_button"
NextPreviousButtonCssClass="next_button" NextPageText="next" />
</Fields>
</asp:DataPager>
但是结果集显示第6个td之后的结果集,而不是整个tr都显示其td下的div,因此我需要在listview中的每两行之后添加一个div.
我可以在特定行之后添加一行吗?
谁能帮助我..
but result set showing every after 6th td it is showing div under its td not in whole tr i need to add a div after every two rows in listview.
can i add a row after a specific rows.
can any one help me please..
推荐答案
如果要在列表视图的每两行中显示DIV,则将(Container.DataItemIndex!= 0&&(Container.DataItemIndex + 1)%6 == 0)设置为(Container.DataItemIndex!= 0&& (Container.DataItemIndex + 1)%3 == 0)您也已经写了它,这就是为什么在TD而不是TR中显示TD的原因,我认为这是正确的,您不能在tr标记中添加div.
Hi,
if you want to display DIV in every two rows in listview then make (Container.DataItemIndex != 0 && (Container.DataItemIndex+1) % 6 == 0) to (Container.DataItemIndex != 0 && (Container.DataItemIndex+1) % 3 == 0) also you have written it in that''s why is diplaying in TD not in TR and that is correct it i think, you can''t add div in tr tag.
<asp:listview id="lst" runat="server" enablemodelvalidation="True" groupitemcount="3" xmlns:asp="#unknown">
InsertItemPosition="none">
<layouttemplate>
<div class="listview-container" style="padding: 5px; width: 750px;">
<div id="groupPlaceholder" runat="server">
</div>
</div>
</layouttemplate>
<grouptemplate>
<div class="listview-group" style="padding: 5px;">
<div id="itemPlaceholder" runat="server">
</div>
<div style="clear: both">
</div>
</div>
</grouptemplate>
<itemtemplate>
<div class="listview-item" style="padding: 5px; float: left; width: 235px;">
<h1>
<%# Eval("Instituename")%></h1>
<h2 style="text-align: left;">
Keywords:
<%# Eval("Keywords")%><br />
Phone:
<%# Eval("Contactno")%>
</h2>
<div class="contact">
<asp:button id="btncontact" runat="server" text="More.." commandargument="<%# Eval("uid") %>" />
</div>
<div style="clear: both">
</div>
</div>
<div style="clear: both; width: 474px;margin-removed10px; ">
<%# (Container.DataItemIndex != 0 && (Container.DataItemIndex + 1) % 6 == 0) ? @" <div id="divadd" style="height: 60px; width: 444px; border: solid 1px #ccc;font-weight:bold;vertical-align:middle;padding-removed35px;font-size:28px;removed: relative;removed -350px;text-align:center;"> Add Inserted Here</div>" : string.Empty%>
</div>
</itemtemplate>
</asp:listview>
我只是放置div而不是td并应用某种样式.现在工作正常...
i just place div instead td''s and apply some sort of styles that it . it is now working fine...
这篇关于将div标签放置在listview控制器中的特定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文