Click here to Skip to main content
15,907,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all..
i have listview control like:
ASP.NET
<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>

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..
Posted
Updated 29-Apr-12 18:48pm
v3
Comments
Sandeep Mewara 28-Apr-12 4:27am    
Not sure how ths html page designed - table-tr-td mixed with itemtempate overlapped.
tulasiram3975 30-Apr-12 0:12am    
yes sir your right overlap takes place how can i solve this problem is my question i have added another tr in layout template but again same thing happening.. i need a layout like
<tr>
<td></td>
<td></td>
<td></td>
<tr>
<tr>
<td colspan='3'></td>
<tr>
Mohamed Mitwalli 28-Apr-12 6:22am    
I'm not sure but i believe your code is Fine and Div should come after td
tulasiram3975 30-Apr-12 0:15am    
yes sir i tried like this also but the problem is it is showing div under a particular td not below of entire row..
Mohamed Mitwalli 30-Apr-12 1:18am    
I tried your code and your div is shown the problem according to you it showing in different place maybe your problem in CSS .

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.
 
Share this answer
 
Comments
tulasiram3975 30-Apr-12 2:03am    
thank you for your replay sir...
Sorry i did't get you.. i need to add div every after two rows here group item count is 3 so am adding after 6th td so this is((Container.DataItemIndex != 0 && (Container.DataItemIndex+1) % 6 == 0)) correct condition if i go like what you say there is a simple way adding group separator thats it...
but here i need to add after every two group items that means every after two rows...
AbdulMuheet 30-Apr-12 2:15am    
Ok so you should try((Container.DataItemIndex != 0 && (Container.DataItemIndex+1) % 9 == 0))
tulasiram3975 30-Apr-12 2:35am    
then it will show div after 9th item. i did 3 items as a group every two rows in the sense 6 items so here i need to add after 6th item not after 9th item
i think you did't get my question right?
solution:
i just place div instead td's and apply some sort of styles that it .
it is now working fine...
ASP.NET
<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>



i just place div instead td's and apply some sort of styles that it . it is now working fine...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900