A
Adam Sandler
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/micr...read/thread/abb4bcc39312a388/2de51eba9a0bcfd6
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>
<asparameter 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(connStringName).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!
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/micr...read/thread/abb4bcc39312a388/2de51eba9a0bcfd6
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>
<asparameter 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(connStringName).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!