We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

ASP.Net ObjectDataSource Issue

Medium Priority
617 Views
Last Modified: 2012-05-11
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
Comment
Watch Question

Paul JacksonSoftware Engineer
CERTIFIED EXPERT
Top Expert 2011

Commented:
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.
Ephraim WangoyaSoftware Engineer
CERTIFIED EXPERT

Commented:

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)
Senior Systems and Integration Developer
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Thank Carl
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.