Solved

Display dataset on aspx page errors in The DataSet in data source 'ObjectDataSource1' does not contain any tables.

Posted on 2010-09-08
4
989 Views
Last Modified: 2012-05-10
Code behind
   oConn.Open()
            'Fill dataset
            oData.Fill(resultSet, "Patient")
            'get data table
            Dim dt As DataTable = resultSet.Tables("Patient")
            GridView1.DataSource = dt.TableName("Patient")
            Page.DataBind()
asp
 <asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1">
    </asp:GridView>
   <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
        SelectMethod="Connect" TypeName="WebApplication1.Login">
    </asp:ObjectDataSource>
</asp:Content>

Why do I keep getting The DataSet in data source 'ObjectDataSource1' does not contain any tables.
Thank you !
Kate
0
Comment
Question by:zagorovskaya
  • 3
4 Comments
 
LVL 21

Expert Comment

by:masterpass
Comment Utility
I have no idea why you have an objectdatasource here when you are binding data from codebehind

if you want to correct codebehind

 Dim dt As DataTable = resultSet.Tables("Patient")
 GridView1.DataSource = dt.TableName("Patient")
 GridView1.DataBind() //its gridview1.databind and not page

now if you want objectdatasource, I suggest you take a look here

http://www.codeproject.com/KB/aspnet/GridViewObjectDataSource.aspx
0
 
LVL 21

Expert Comment

by:masterpass
Comment Utility
and forgot to mention why you are getting this error ... its because your select method of the objectdatasource is not returning any data at all ... I would suggest you check the return in your Select() method of ObjectDataSource. If it does not contain any table, create an empty one.
0
 

Author Comment

by:zagorovskaya
Comment Utility
Thanks a lot Sage. I removed the ObjectDataSource from aspx and got this error

The DataSourceID of 'GridView1' must be the ID of a control of type IDataSource.  A control with ID 'ObjectDataSource1' could not be found.

I am new to .net. Trying to figure it out.  here is how it is now:
 
 Dim dt As DataTable = resultSet.Tables("Patient")
  GridView1.DataSource = dt.TableName("Patient")
  GridView1.DataBind()
 and
 
     </p>
    <asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1">
    </asp:GridView>

and it says I am missing ObjectDataSource
0
 
LVL 21

Accepted Solution

by:
masterpass earned 50 total points
Comment Utility
I think you forgot to remove the reference of the objectdatasource from the gridview markup

 <asp:GridView ID="GridView1" runat="server" >
    </asp:GridView>

remove the  DataSourceID="ObjectDataSource1" from gridview and you will be good to go
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

6 Experts available now in Live!

Get 1:1 Help Now