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
1,000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

735 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