【发布时间】:2013-06-14 20:55:39
【问题描述】:
我有一个简单的对象数据源,形式为 IENumerable<MyClass>,其中 MyClass 是:
class MyClass(){
public DateTime Key;
public Int Value1;
public Int Value2;
public Int Value3;
}
我希望在设计时使用 ObjectDataSource 对它进行数据绑定,而不是声明式的。 我希望这是:
<asp:Chart runat="server" DataSourceID="datasource">
<Series>
<asp:Series XValueMember="Key" YValueMembers="Value1"/>
<asp:Series XValueMember="Key" YValueMembers="Value2"/>
</Series>
</asp:Chart>
<asp:ObjectDataSource ID="datasource" runat="server" SelectMethod="DataObjectMethodName" TypeName="DataObjectClassName"/>
然而,每当我尝试对这个映射进行数据绑定时,我都会收到以下异常:
Series data points do not support values of MyClass only values of these types can be used: Double, Decimal, Single, int, long, uint, ulong, String, DateTime, short, ushort.
我还尝试让我的数据源返回 Dictionary<DateTime, Int[]> 和 Dictionary<DateTime, MyClass>,但没有成功。
MSCharts 不支持对复杂对象的简单设计时数据绑定吗?我能够绑定到Dictionary<DateTime, int>。
最后,这应该是 StackedColumn 类型的图表。
我看到过类似的问题,例如 Multiple columns chart using asp.net chart control 没有回答这个问题。
【问题讨论】:
标签: data-binding mschart design-time