Link to home
Start Free TrialLog in
Avatar of MadhuMenong
MadhuMenongFlag for India

asked on

ASP.Net ObjectDataSource Issue

Dear Friends,

Please refer to the below link to understand my question.

http://quickstarts.asp.net/QuickStartv20/util/srcview.aspx?path=~/aspnet/samples/data/GridViewDAL.src&file=GridViewObject_cs\GridViewDAL_cs.aspx&lang=C%23+Source

We have an AuthorsDB.cs in App_Code folder.

If I move the AuthorsDB.cs from the App_Code folder to and my application folder and run the example I get the following error.

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

But when I put AuthorsDB.cs back into the App_Code it works perfectly.

My question is what if I dont want my class files in App_Code but in my own defined folder then what changes is required to make the application work.

Thank you
Madhu Menon
Avatar of Paul Jackson
Paul Jackson
Flag of United Kingdom of Great Britain and Northern Ireland image

The App_Code folder is a special folder used to hold class files that get compiled so that the code can be used by other pages in your solution. If you move the class file to another folder it won't get compiled hence why you get the error described.
The only alternative is to create a Class Library project within your solution and move the class files into the class library. You will then have to add a reference to the class library in your project and you can call the code from your project.

Copy AuthorsDB.c to the folder you want to be

Right click on the file and remove the item from App_Code

Right click on the folder you copied it to and select Add Item then choose the file

Save project

(Make sure you copy it before removing)
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MadhuMenong

ASKER

Thank Carl