473,397 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Data in DataSet but GridView will not display

Hello,

Prior to posting I looked at http://groups.google.com/group/
microsoft.public.dotnet.framework.aspnet/browse_thread/thread/
d8d5ae243614085e/d4fd6c4a5aa56f75

http://groups.google.com/group/micro...e51eba9a0bcfd6

Hello,

I'm having a problem with getting a GridView to display data. Debug
shows there is indeed data in the DataSet behind the grid (more on
that later). But after DataBind() is called, the grid is not
displayed on the page.

On the page, here's the markup:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:devConnectionString %>"
SelectCommand="SELECT * FROM [DataChron] WHERE ([SensorID] =
@SensorID)">

<SelectParameters>
<asp:Parameter Name="SensorID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server"></asp:GridView>

Here's there web.config entry:

<connectionStrings>
<add name="devConnectionString" connectionString="Data
Source=CSFDCRW\SQLEXPRESS;Initial Catalog=dev;Integrated
Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

in the codebehind here's some of the code:

Dim mySensor As New Sensor
Me.GridView1.DataSource = mySensor.getSensorData(s)
Me.GridView1.DataBind()

and here is the method in Sensor:

Function getSensorData(ByVal s As String) As Data.DataSet
Dim connStringName As String = "devConnectionString"
Dim connString As String = _

ConfigurationManager.ConnectionStrings(connStringN ame).ConnectionString

Dim myConnection As New Data.SqlClient.SqlConnection(connString)

Dim sql As String = "SELECT * FROM [DataChron] WHERE ([SensorID] =
'" & s & "')"

Dim myCommand As New Data.SqlClient.SqlCommand(sql, myConnection)

Dim myDataSet As New Data.DataSet

Dim myAdapter As New Data.SqlClient.SqlDataAdapter(myCommand)
myAdapter.Fill(myDataSet)

getSensorData = myDataSet

myConnection.Close()
End Function
During debug, for the line:

"SELECT * FROM [DataChron] WHERE ([SensorID] = '" & s & "')"

the Autos window days:

SELECT * FROM [DataChron] WHERE ([SensorID] = '7747')

and if I paste that SQL statement into a SQL pane in SQL Server
Management Studio, I get 3 rows back!

stepping into this line:

getSensorData = myDataSet

the Autos window says:

Tables.Count = 1

stepping into the line:

Me.GridView1.DataBind()

the Autos window says

Me.GridView1.DataSource = {System.Data.DataSet}
Me.GridView1.Rows.Count 3

Again, my code found 3 rows in the database based upon the parameter.
A DataSet is returned to the calling method. That Dataset is linked
to the Gridview and then DataBind is called. But when DataBind is
called... nothing happens!

Any suggestions on how I can get the results in the grid to be
displayed are greatly appreciated.

Thanks!

Feb 16 '07 #1
0 4307

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the...
4
by: washoetech | last post by:
Hello, I am working on a project where I need to be able to grab the data from an Excel spreadsheet and create a new table in my database based on the columns in the spreadsheet. After the...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
5
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the...
2
by: Nick Hodge \(MVP\) | last post by:
Hi I currently have a gridview connected to a SQLDatasource. (This data comes from a remote iSeries). It shows catalogue sales as they build during the day (works great). I have a local SQL...
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
0
by: arun | last post by:
Hi I have a GridView which I will bind to different DataTables in a DataSet. There is a UserControl which will have as many number of buttons as the number of DataTables in the DataSet. When I...
1
by: Dave | last post by:
I'm having problems getting the GridView to reliably display a large amount of data (50,000+ rows). I am working my way through the excellent book “Real World ASP.NET Best Practices” by Farhan...
1
by: readnlearn | last post by:
Hii, in my table I have fields like id1,title,description,category,posteddate..In my gridview I wish to display title,posteddate and category. I placed a hyperlink for title field. Now when I click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.