2017-01-12 26 views
0

我有一個listview(不是gridview),我想在一個單元格中放入相同的結果。
我不能像gridview一樣使用rowspan,因爲listview沒有這個方法。
我現在擁有的一切:如何在listview中製作rowspan?

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

我想有什麼

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

我的代碼:

<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> 

我想環路 - 選擇一個值,並跳過1,但它不是很有效。

我用Asp.net,EF,LINQ

我在C#中選擇方法:

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 
              } 

請清晰地閱讀。 我如何結合我的結果來使rowspan?
如果我只是寫行rows我會添加SAMPLE結果,我需要添加它像:索引[0]值,索引值[1],索引值[2]。

+0

你想要的是['rowspan'](http://www.w3schools.com/TAgs/att_td_rowspan.asp)而不是'colspan' – Liam

+0

可能的重複[你如何在HTML表中使用colspan和rowspan? ](http://stackoverflow.com/questions/9830506/how-do-you-use-colspan-and-rowspan-in-html-tables) – Liam

+0

@Liam它不是重複的。它的另一個問題 –

回答

1

嘗試類似下面

<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> 

綁定ListView1的的ItemDataBound事件的數據。

+0

我有datakeyname pcod,並且我從公共無效ListView1_UpdateItem(字符串pcod) { pcodik = pcod; GetDoctors(); }。如果我不知道datakeyname(我的表的列),我該如何綁定它? –

+0

是的!您的解決方案正常工作非常感謝你! –