aspx:
<asp:Repeater id="RP_Leader_Now" runat="server"
onitemcommand="RP_Leader_ItemCommand" OnItemDataBound="RP_Leader_Now_ItemDataBound">
<HeaderTemplate>
<table width="670" align="center" cellpadding="0" bgcolor="#88C8EC">
<tr>
<th align="center" bgcolor="#F2FBFF" class="song12blue01">1</th>
<th align="center" bgcolor="#F2FBFF" class="song12blue01">2</th>
<th align="center" bgcolor="#F2FBFF" class="song12blue01">3</th>
<th align="center" bgcolor="#F2FBFF" class="song12blue01">4</th>
<th align="center" bgcolor="#F2FBFF" class="song12blue01">5</th>
<th align="center" bgcolor="#F2FBFF" class="song12blue01">6</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td align="center" bgcolor="#FFFFFF" class="song12blue03" rowspan="<%#GetRowsCount(Eval("CarList"))%>"> <%#Eval("ID")%></td>
<td align="center" bgcolor="#FFFFFF" class="song12blue03" rowspan="<%#GetRowsCount(Eval("CarList"))%>"> <%#Eval("ID")%></td>
<td align="center" bgcolor="#FFFFFF" class="song12blue03"> <%#GetCarID(Eval("CarList"))%></td>
<td align="center" bgcolor="#FFFFFF" class="song12blue03"> <%#GetCarID(Eval("CarList"))%></td>
<td align="center" bgcolor="#FFFFFF" class="song12blue03"> <%#GetCarID(Eval("CarList"))%></td>
<td align="center" bgcolor="#FFFFFF" class="song12blue03"> <%#GetCarID(Eval("CarList"))%></td>
</tr>
<asp:Repeater id="RP_Car_Now" runat="server">
<ItemTemplate>
<tr>
<td align="center" bgcolor="#FFFFFF" class="song12blue03"> <%#Eval("CarID")%></td>
<td align="center" bgcolor="#FFFFFF" class="song12blue03"> <%#Eval("CarID")%></td>
<td align="center" bgcolor="#FFFFFF" class="song12blue03"> <%#Eval("CarID")%></td>
<td align="center" bgcolor="#FFFFFF" class="song12blue03"> <%#Eval("CarID")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
C#:
//输出数据例子
IList<MdlLeaderInfo> data
{
get
{
IList<MdlLeaderInfo> _data = new List<MdlLeaderInfo>();
MdlLeaderInfo li1 = new MdlLeaderInfo();
li1.ID = "li1";
MdlLeaderInfo li2 = new MdlLeaderInfo();
li2.ID = "li2";
MdlLeaderInfo li3 = new MdlLeaderInfo();
li3.ID = "li3";
MdlLeaderCar lc1 = new MdlLeaderCar();
lc1.CarID = "lc1";
MdlLeaderCar lc2 = new MdlLeaderCar();
lc2.CarID = "lc2";
MdlLeaderCar lc3 = new MdlLeaderCar();
lc3.CarID = "lc3";
IList<MdlLeaderCar> lcList1 = new List<MdlLeaderCar>();
IList<MdlLeaderCar> lcList2 = new List<MdlLeaderCar>();
lcList1.Add(lc1);
lcList2.Add(lc2);
lcList2.Add(lc3);
li1.CarList = lcList1;
li2.CarList = lcList2;
_data.Add(li1);
_data.Add(li2);
_data.Add(li3);
return _data;
}
}
//列表信息绑定
private void LeaderBind_Now()
{ this.RP_Leader_Now.DataSource = data;
this.RP_Leader_Now.DataBind();
}
//内层表信息绑定
protected void RP_Leader_Now_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
MdlLeaderInfo mdlLeaderInfo = e.Item.DataItem as MdlLeaderInfo;
Repeater RP_Car = e.Item.FindControl("RP_Car_Now") as Repeater;
if (mdlLeaderInfo != null && RP_Car != null)
{
if (mdlLeaderInfo.CarList == null || mdlLeaderInfo.CarList.Count == 0)
RP_Car.DataSource = mdlLeaderInfo.CarList;
else
{
mdlLeaderInfo.CarList.RemoveAt(0);
RP_Car.DataSource = mdlLeaderInfo.CarList;
}
RP_Car.DataBind();
}
}
效果图:
- 大小: 2.5 KB