0

I have a listview(not a gridview) and i want to put same results in one cell.
I can't make it with rowspan like in gridview, because listview didn't have this method.
What i have now :

FullName  | LgotName | 
------------------------                           
John      |First     |                        
John      |Second    |                          
John      |Third     |    

What i want to have

FullName  | LgotName | 
------------------------                           
John      |First     |
          |----------|            
          |Second    | 
          |----------| 
          |Third     | 
------------------------ (this is end of John row)

My code:

 <asp:ListView ID="ListView1" runat="server"... >
                <LayoutTemplate>
                    <div class="outerContainer">
                        <table id="docnewTable">
                            <thead>
                                <tr>
                                    <th>Full Name</th>
                                    <th>LgotName</th>
                                <th></th>
                                    <th></th>
                                </tr>
                            </thead>

                            <tbody runat="server" id="itemPlaceholder"></tbody>
                        </table>
                    </div>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr>
                        <td><%# Item.fam_v %></td>
                        <td><%# Item.im_v %></td>
                        <td>
                            <asp:Button ID="ChangeDocBtn" runat="server"  />
                        </td>
                        <td>
                            <asp:Button ID="DeleteDocBtn" runat="server" Text="Delete  />
      </td>
     </tr>
                </ItemTemplate>
      </asp:ListView>

I think about loop - select one value, and skip 1 , but it not very effective.

I use Asp.net, EF, linq

My Select method in c# :
I

Enumerable<FinalDoc> fidn = from post in repository.doctors
                                             join meta in repository.DoctorsLG on post.pcod equals meta.pcod
                                             join thir in repository.SP_lgota on meta.idGK equals thir.C_LGT
                                             where post.actual == 1                                                  select new FinalDoc
                                             {
                                                 mcod = post.mcod,
                                                 pcod = post.pcod,
                                                 c_ogrn = post.c_ogrn,
                                                 fam_v = post.fam_v,
                                                 im_v = post.im_v,
                                                 ot_v = post.ot_v,
                                                 idGK = meta.idGK,
                                                    LgotName = thir.LgotName
                                             }

PLEASE READ IT CLEARLY . How can i combine my results to make rowspan ?
If i just write rowspan i will add SAMPLE RESULTS , and i need to add it like : value with index[0], value with index[1], value with index[2].

1 Answers1

1

Try something like below

    <asp:ListView ID="ListView1" runat="server"... >
                        <LayoutTemplate>
                            <div class="outerContainer">
                                <table id="docnewTable">
                                    <thead>
                                        <tr>
                                            <th>Full Name</th>
                                            <th>LgotName</th>
                                        <th></th>
                                            <th></th>
                                        </tr>
                                    </thead>

                                    <tbody runat="server" id="itemPlaceholder"></tbody>
                                </table>
                            </div>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <tr>
                                <td><%# Item.fam_v %></td>
                         <td>       
        // Place new Listview here like
       <table> <asp:ListView ID="ListView2" runat="server">
<tr>
<td><%# Item.im_v %></td>
</tr>
</asp:ListView>
</table>
</td>

                                <td>
                                    <asp:Button ID="ChangeDocBtn" runat="server"  />
                                </td>
                                <td>
                                    <asp:Button ID="DeleteDocBtn" runat="server" Text="Delete  />
              </td>
             </tr>
                        </ItemTemplate>
              </asp:ListView>

Bind the data on Itemdatabound event of ListView1.

Ankit
  • 760
  • 6
  • 15
  • I have datakeyname pcod, and i take it from public void ListView1_UpdateItem(string pcod) { pcodik = pcod; GetDoctors(); } . How i can bind it if i didn't know datakeyname (column of my table) ? – Андрей Голубцов Jan 12 '17 at 14:45