Asp.net objectdatasource TypeName property error

I am using ASP:ObjectDataSource to bind grid data.

My problem is that when I run this code, I get an error.

 <asp:ObjectDataSource ID="odsListing" runat = "server" SelectMethod = "MethodNameOfCodeBehindClass" TypeName = "FolderName_CodeBehindClassName" ></asp:ObjectDataSource> 

Error message

 The type specified in the TypeName property of ObjectDataSource 'odsListing' could not be found. 

Therefore, I am moving my code to the codebehind site.

  #region ObjectDataSource for Grid Binding Type type = typeof(FolderName_CodeBehindClassName); string assemblyQualifiedName = type.AssemblyQualifiedName; odsListing.TypeName = assemblyQualifiedName; odsListing.SelectMethod = "ListingDatabind"; #endregion 

Now everything is all right. This is a job. But I would like to know the actual solution to my problem. Why does this cause an error?

In fact, I do not want to move my code to the codebehind layer if it can write at the development level.

Every suggestion will be appreciated.

+2
source share
1 answer

The problem is that you are using a short type name instead of the full type name.

Replace FolderName_CodeBehindClassName with The.NameSpace.YouHaveYourTypeIn.FolderName_CodeBehindClassName, Name.Of.Your.Assembly .

+3
source

Source: https://habr.com/ru/post/959173/


All Articles