ASP.NET and DataSets

Posted on 2012-09-11
Last Modified: 2013-03-07
I have a Classic ASP application that uses an MS SQL Server database.  I am going to migrate the ASP app to ASP.NET and make some enhancements.  I will be making some changes to the database tables for this enhancement.  

I created a new DataSet and added datatables manually to the DataSet to represent the changes I will be making for the enhancement.  (I can't change the database yet and don't want to wait to begin my development.)

What I need to do now is add a GridView to my form using data from a table in my newly created DataSet.  When I choose Object as my DataSource Type, it doesn't allow me to choose my new DataSet even though it exists in my App_Code folder.

My plan is to populate the new DataSet during the PageLoad Event as a temporary measure until I can make the database changes.

I am using VS 2010.  Any help would be greatly appreciated!
Question by:dyarosh
    LVL 9

    Expert Comment

    Can you post the detailed error message for the DataSet issue you facing?
    LVL 9

    Expert Comment

    if you use database store procedure with dump/temporary data to return it will work
    for e.g. if u use store procedure like usp_user
    create proc usp_user
    --- select userid, username, activedeactive from usertable
       select 23 , 'sampleuser23' , 1 union all
       select 53 , 'sampleuser53' , 1 union all
       select 26 , 'sampleuser26' , 1 union all
       select 73 , 'sampleuser73' , 0
    LVL 20

    Expert Comment

    DataSet1 ds = new DataSet1();
    gv.DataSource = ds.Tables[0];

    Open in new window


    Author Comment

    I knew how to do it programmatically.  What I really want to be able to do is to do it in the IDE so I can format the gridview and set it up for editing.  

    So maybe a better question is how can I create a DataSet that is not tied to a database.  If I have to I could create an XML file or Text file to simulate the database but I was hoping I could just define the tables in the DataSet and then programmatically populate the tables in the DataSet.  If the DataSet and tables existed in the IDE I would then use it to bind to different controls on my form and then once the database on my system can be changed I would modify my DataSet to be configured to my database.

    Am I making more sense?
    LVL 20

    Accepted Solution

    I don't think you can bind a typed dataset to gridview in design time. You have to do it from server-side.

    Alternatively I think you could just creat an XML file and bind the Gridview using a XMLDataSource. That way you can do it designtime.

    Author Comment

    So if I create an XML file and bind the Gridview using an XMLDataSource I should be able to format the Grid the way I want it to look and behave.  When I am finally able to make the changes to my SQL Database, do I just change my datasource on my DataSet if the tables are laid out the same?  Will I have to change anything with the Gridview processing?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    758 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

    11 Experts available now in Live!

    Get 1:1 Help Now