ASP.Net ObjectDataSource Issue

Posted on 2011-04-19
Last Modified: 2012-05-11
Dear Friends,

Please refer to the below link to understand my question.\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
Question by:MadhuMenong
    LVL 29

    Expert Comment

    by:Paul Jackson
    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.
    LVL 32

    Expert Comment


    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)
    LVL 52

    Accepted Solution

    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.

    Author Closing Comment

    Thank Carl

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
    Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
    Viewers will learn how the fundamental information of how to create a table.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now