【发布时间】:2012-08-23 10:19:01
【问题描述】:
我使用ASP:ObjectDataSource 进行网格数据绑定。
我的问题是当我运行此代码时出现错误。
<asp:ObjectDataSource ID="odsListing"
runat = "server"
SelectMethod = "MethodNameOfCodeBehindClass"
TypeName = "FolderName_CodeBehindClassName" ></asp:ObjectDataSource>
错误信息
The type specified in the TypeName property of
ObjectDataSource 'odsListing' could not be found.
所以我将我的代码移动到代码隐藏站点。
#region ObjectDataSource for Grid Binding
Type type = typeof(FolderName_CodeBehindClassName);
string assemblyQualifiedName = type.AssemblyQualifiedName;
odsListing.TypeName = assemblyQualifiedName;
odsListing.SelectMethod = "ListingDatabind";
#endregion
现在一切正常。这是工作。 但我想知道我的问题的实际解决方案。 为什么会报错?
实际上,如果可以在设计层编写代码,我不想将代码移动到代码隐藏层。
我们将不胜感激。
【问题讨论】:
标签: c# asp.net objectdatasource