【发布时间】:2014-11-08 11:41:48
【问题描述】:
我有一个字典列表,我这样创建它:
List<Dictionary<String, String>> _list = new List<Dictionary<string, string>>();
var q = from d in db.TT_DELIVERies
where d.DeliveryOrderNumber == donumber
select new { d.DeliveryId };
if (q.Count() > 0)
{
var qd = from d in db.TT_DELIVERY_REQUESTs
where d.DeliveryOrderId == q.ToList()[0].DeliveryId
select new { d.ItemDescription, d.PackageDescription };
Console.Write(qd.Count());
if (qd.Count() > 0)
{
foreach (var r in qd)
{
Dictionary<String, String> temp = new Dictionary<string, string>();
temp.Add("Name", r.ItemDescription);
temp.Add("Desc", r.PackageDescription);
_list.Add(temp);
}
}
}
我尝试像这样与中继器绑定:
rptAddedDocs.DataSource = _list;
rptAddedDocs.DataBind();
这是我的中继器
<asp:Repeater ID="rptAddedDocs" runat="server">
<HeaderTemplate>
<table id="tblListAddedDocs" class="table table-condensed table-hover">
<thead>
<tr>
<th>No</th>
<th>Document Name</th>
<th>Quantity</th>
<th>UOM</th>
<th>Description</th>
<th></th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>1</td>
<td><%# Eval("Name")%> </td>
<td>1 </td>
<td>Envlope </td>
<td><%#Eval("Desc")%> </td>
<td></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
但我得到这样的错误:
DataBinding: 'System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' does not contain a property with the name 'Name'.
请帮助我如何正确使用带有字典列表的中继器?
【问题讨论】:
标签: c# asp.net dictionary