• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 600
  • Last Modified:

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
0
MadhuMenong
Asked:
MadhuMenong
1 Solution
 
Paul JacksonCommented:
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.
0
 
Ephraim WangoyaCommented:

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)
0
 
Carl TawnSystems and Integration DeveloperCommented:
You other option is to convert your website project into a Web Application project, then you don't need the App_Code folder at all.
0
 
MadhuMenongAuthor Commented:
Thank Carl
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now