我有一个这样定义的 LinqDataSource:
<asp:LinqDataSource ID="LinqDataSource1" runat="server" OnSelecting="LinqDataSource_FileSelecting"></asp:LinqDataSource>
在 LinqDataSource_FileSelecting 中,它返回/设置 aList<string>
到 e.Result,其中 e 是 LinqDataSource 的 Selecting 事件中的 EventArgs (LinqDataSourceSelectEventArgs)。页面加载时出现此错误:
“LinqDataSource 'LinqDataSource1' 的 ContextTypeName 属性必须指定数据上下文类型。”
根据此消息并查看文档,我需要设置 LinqDataSource 的 ContextTypeName 和 TableName 属性。ContextTypeName 通常是类的名称,TableName 是该类中可枚举属性的名称。
当数据源是List<string>
我不确定我可以分配什么 ContextTypeName 或 TableName 时。我尝试System.Collections.Generic.List<string>
了 ContextTypeName,但没有用,我收到“无法加载类型' System.Collections.Generic.List<string>
'”
List<string>
当数据源在 Selecting 事件中生成时,我意识到 LinqDataSource 可能不是适当的控件。但是我可以为这种情况设置 ContextTypeName 和 TableName 吗?