[问题] asp.net c# repeater取出List资料

楼主: areyo (没有名字的怪物)   2017-12-08 22:59:22
晚安
想请教一下,我有个Class其结构如下
public class TotalMoneyClass
{
public List<string> DateStrList = new List<string>();
public List<int> CheckMoneyList = new List<int>();
public string storeName { get; set; }
};
然后我用个List<TotalMoneyClass>去存资料
foreach(string nameStr in mStore){
TotalMoneyClass tmp = new TotalMoneyClass();
tmp.storeName = nameStr;
for (int month = 1; month < 13; month++)
{
//若没有资料,就当作0
tmp.CheckMoneyList.Add(result.Where(i => i.mStoreName.CompareTo(nameStr) == 0 && i.shop_date.Month == month && i.shop_date.Year == 2017)
.Sum(t =>(int?) t.totalSale_money)??0);
}
listStore.Add(tmp);
}
Repeater1.DataSource = listStore;
Repeater1.DataBind();
而我想要用Repeater去呈现出TotalMoneyClass里的List<int> CheckMoneyList
那该怎么改写呢??
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound" >
<HeaderTemplate>
<table>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# ((TotalMoneyClass)Container.DataItem).storeName %></td>
<td><%# ((TotalMoneyClass)Container.DataItem).CheckMoneyList %></td>
</tr>
</ItemTemplate>
</asp:Repeater>
谢谢
作者: ian90911 (xopowo)   2017-12-09 14:22:00
你是要循环印出CheckMoneyList变成每一栏td吗
楼主: areyo (没有名字的怪物)   2017-12-09 18:05:00
是的,可以用repeater吗??
作者: Tony427 (重新出发...fight!!)   2016-01-04 16:14:00
repeater不熟...我都用Razor Page...XD

Links booklink

Contact Us: admin [ a t ] ucptt.com