Frank Myat Thu
Frank Myat Thu

Reputation: 4474

Asp.net objectdatasource TypeName property error

I use ASP:ObjectDataSource for grid data binding.

My problem is when I run this code I get 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.

So I move my code to codebehind site.

    #region ObjectDataSource for Grid Binding
    Type type = typeof(FolderName_CodeBehindClassName);
    string assemblyQualifiedName = type.AssemblyQualifiedName;

    odsListing.TypeName = assemblyQualifiedName;
    odsListing.SelectMethod = "ListingDatabind";
    #endregion

Now Everythings is ok. It is work. But I would like to know actual solution for my problem. Why it raise error?

Actually, I don't want to move my code to codebehind layer if it can write at design layer.

Every suggestion will be appreciated.

Upvotes: 2

Views: 4150

Answers (1)

Wiktor Zychla
Wiktor Zychla

Reputation: 48230

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

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

Upvotes: 4

Related Questions