[問題] asp.net c# repeater取出List資料
晚安
想請教一下,我有個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>
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.174.243.17
※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1512745166.A.315.html
推
12/09 14:22,
7年前
, 1F
12/09 14:22, 1F
→
12/09 18:05,
7年前
, 2F
12/09 18:05, 2F
→
01/04 16:14,
8年前
, 3F
01/04 16:14, 3F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章