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
992 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
ID: 33633171
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
ID: 33633174
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
ID: 33638124
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
ID: 33642989
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

939 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

10 Experts available now in Live!

Get 1:1 Help Now