日期:2014-05-18  浏览次数:20377 次

如何實現gridview 一對多
想做到像下圖這樣:


------解决方案--------------------
探讨
想做到像下圖這樣:

------解决方案--------------------
用datalist写吧 还可以设置table样式


<asp:DataList ID="DL_it" runat="server" CellPadding="4" Width="100%" Style="word-wrap: break-word;
word-break: break-all;" OnItemDataBound="DL_it_ItemDataBound" ForeColor="#333333" OnItemCommand="DL_it_ItemCommand">
<HeaderTemplate>
<table align="right">
<tr>
<td align="right">
共有<%=count %>条记录。
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table runat="server">
<tr visible="false">
<td>
<asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"id") %>'></asp:Label>
<asp:Label ID="Label2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"wname") %>'></asp:Label>
<asp:Label ID="Label3" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"del") %>'></asp:Label>
</td>
</tr>
<tr>
<td align="left">
[<asp:LinkButton ID="LinkButton4" runat="server" CommandName="_sort"><%# DataBinder.Eval(Container.DataItem,"sort") %></asp:LinkButton>]
<asp:LinkButton ID="LinkButton5" runat="server" CommandName="_title"><%# DataBinder.Eval(Container.DataItem,"title") %></asp:LinkButton>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="modify"><img src="..\images\upd.gif" border="0">修改</asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="delete"><img src="..\images\dele.gif" border="0">删除</asp:LinkButton>
</td>
</tr>
<tr>
<td align="left">
<asp:Label ID="Label4" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"zhaiyao") %>'></asp:Label>
</td>