C# 在listview asp.net c中绑定listview#
我想在listview中绑定listview。我有一个对象,其中包含另一个对象列表对象 这里我有一个result对象,其中还有一个weeklyresult(List)对象。 我正在尝试将外部列表与结果对象绑定 以下是cs代码: 在resultListobject中填充数据:C# 在listview asp.net c中绑定listview#,c#,asp.net,.net,listview,C#,Asp.net,.net,Listview,我想在listview中绑定listview。我有一个对象,其中包含另一个对象列表对象 这里我有一个result对象,其中还有一个weeklyresult(List)对象。 我正在尝试将外部列表与结果对象绑定 以下是cs代码: 在resultListobject中填充数据: ResultListView.DataSource = resultList; ResultListView.DataBind();
ResultListView.DataSource = resultList;
ResultListView.DataBind();
Response.Write(resultList);
课程结果和每周结果:
class Result {
public string examDate { get; set; }
public List<WeeklyResult> weeklyResultList = null;
}
class WeeklyResult {
public string subject { get; set; }
public double marksObtained { get; set; }
public double outOff { get; set; }
}
类结果{
公共字符串examDate{get;set;}
公共列表weeklyResultList=null;
}
课程周结果{
公共字符串主题{get;set;}
公共双标记包含{get;set;}
公共双输出{get;set;}
}
下面是我的asp.net代码:
<asp:ListView ID="ResultListView" runat="server">
<ItemTemplate>
<asp:Label runat="server"></asp:Label>
<table id="Table1" runat="server">
<tr>
<td>Date :<%#Eval("examDate")%> </td>
<td>Marks Obtained</td>
<td>Out off</td>
</tr> </table>
<asp:ListView ID="InnerListView" runat="server">
<ItemTemplate>
<asp:Label ID="Label0" runat="server" Text="abc<%#Eval('weeklyResultList.subject')%>"></asp:Label>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>
<asp:Label ID="Label3" runat="server" Text=""></asp:Label>
</ItemTemplate>
</asp:ListView>
</ItemTemplate>
</asp:ListView>
日期:
获得的分数
出去
外部列表中的数据即将出现,但内部列表中没有显示任何内容。
你能告诉我我做错了什么吗
谢谢,
Amandeep必须使用:
DataSource='<%#Eval("weeklyResultList")
DataSource='尝试将内部ListView绑定到第一个ListView中。只需分配其他数据源。它只会解决你的问题