473,528 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data in dataset but not displaying in gridview

49 New Member
Hello, I'm new to this asp.net 2.0 I need help??
My database is coming from AS400 which uses odbc Commands. i have data in the dataset but nothing showing in my gridview. However the data does show on the page. Could you please see what I'm doing wrong.

My code is down below
Expand|Select|Wrap|Line Numbers
  1.  Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
  2.  
  3.  
  4.         Dim myconnection As OdbcConnection
  5.         Dim myCommand As OdbcDataAdapter
  6.         Dim mydataset As New DataSet
  7.         Dim gvResults As DataTable
  8.         Dim loop1 As Integer
  9.         Dim numrows As Integer
  10.         Dim mysql As String
  11.         Dim Order As Integer
  12.         Order = CInt(txtOrderNumber.Text)
  13.  
  14.  
  15.         mysql = "select  line#, ordno, quano, quana, quans, c2rdt, unitm, prdno, actsp  from rmsfiles2.obcop200 where ordno = " & Order
  16.         myconnection = New OdbcConnection("DRIVER=Client Access ODBC Driver (32-bit);UID=ODBC;PWD=XXXXX;System=xxx.xxx.xxx.xxx")
  17.  
  18.         myCommand = New OdbcDataAdapter(mysql, myconnection)
  19.  
  20.         myCommand.Fill(mydataset, "OBCOP200")
  21.  
  22.         gvResults = New DataTable
  23.         gvResults = mydataset.Tables(0)
  24.  
  25.         numrows = gvResults.Rows.Count
  26.  
  27.         If numrows = 0 Then
  28.             txtOrderNumber.Text = "Order#" & txtOrderNumber.Text & " invalid order number"
  29.  
  30.         Else
  31.             txtOrderNumber.Text = ""
  32.  
  33.             For loop1 = 0 To numrows - 1
  34.  
  35.                 Response.Write(Server.HtmlEncode(gvResults.Rows(loop1).Item("ordno")) & " " & Server.HtmlEncode(gvResults.Rows(loop1).Item("quano")) & " " & Server.HtmlEncode(gvResults.Rows(loop1).Item("quana")) & " " & Server.HtmlEncode(gvResults.Rows(loop1).Item("quans")) & " " & Server.HtmlEncode(gvResults.Rows(loop1).Item("c2rdt")) & " " & Server.HtmlEncode(gvResults.Rows(loop1).Item("unitm")) & " " & Server.HtmlEncode(gvResults.Rows(loop1).Item("prdno")) & " " & Server.HtmlEncode(gvResults.Rows(loop1).Item("actsp")) & " <br>")
  36.  
  37.  
  38.             Next loop1
  39.             gridview1.DataBind()
  40.         End If
  41.  
  42.         gridview1.DataSource = mydataset.Tables("OBCOP200").DefaultView
  43.         gridview1.DataBind()
  44.         gridview1.Visible = True
Sep 11 '07
51 7852
Frinavale
9,735 Recognized Expert Moderator Expert
Ok I try it. Nothing comes up when I do a number however when I type in name it comes up with please supply a valid number. What should we do
I suggest starting a new project and learning how to use the GridView object before continuing with what you are doing.

MSDN has a library on everything you would like to know about .NET.
See the MSDN article on the GridView Class. Near the bottom there are links to a whole bunch of walkthoughs that will help you learn this object. Farther down in the article there is an example.

So I suggest starting a new project with just one aspx page in...and a GridView object (and label that you can use to display errors).

Once you can get data to appear in your GridView, try adding in the database stuff.

-Frinny
Sep 13 '07 #51
Frinavale
9,735 Recognized Expert Moderator Expert
This thread has a section removed from it.
See the thread on
'MachineToApplication' beyond application level Error
for the part that has been removed.
Sep 13 '07 #52

Sign in to post your reply or Sign up for a free account.

Similar topics

7
14787
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 want to look at that data and filter it based on what is in it. I know that this could have been done with data sets and data views in asp.net 1.1...
0
4314
by: Adam Sandler | last post by:
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/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/abb4bcc39312a388/2de51eba9a0bcfd6 Hello,
1
1728
by: MikeB | last post by:
ooh boy, I hope I'm in the right place to ask this. I'm trying to do a class project that binds controls to data sources. I have a Drop-down List that I bound to the Author column of an SQL table Articles. I then have a GridView that is supposed to react to changes in the name selected in the DDL.
2
2841
by: Steve Kershaw | last post by:
Hi, I'm working on a project in which I have a Gridview that has data. That Gridview data must be then exported to an Excel spreadsheet. I have successfully displayed the Excel spreadsheet and fill it with data using the Range.InvokeMember(...) method: Range range2 = worksheet.get_Range("A1", "L1"); Object args2 = new Object;
6
9068
by: marylipscomb | last post by:
I am using VB.NET. I am trying to connect a button so that when it is clicked the gridview pops up the data. Partial Class Switchboard Inherits System.Web.UI.Page Protected Sub btnLookup_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLookup.Load If Not Page.IsPostBack Then Dim queryString...
2
1247
by: mathewgk80 | last post by:
Hi all, I would like to know how can i view a grid in page load.... I dont bind any data into tht gridview.. But i want to show the grid header and footer in the page.. I am using asp.net and c#.net... Please help me...
2
4402
by: =?Utf-8?B?VmFpYmhhdg==?= | last post by:
I am trying to populate dataset from gridview but it's not working . Can anyone plz tell me how to do it..
2
2283
by: satwinder singh | last post by:
Please help me regarding how to Export the Data from DataSet or GridView into Excel sheet. Kind Regards, Satwinder singh
5
23962
by: satyabhaskar | last post by:
hi, I want to bind the data from the Dataset to GridView When I run my code I get the error The type or namespace name 'DataRows' could not be found (are you missing a using directive or an assembly reference?) I have called the following assemblies using System; using System.Data; ...
1
3008
by: Vidya A | last post by:
How to bind dataset to gridview in asop.net with vb using code
0
7332
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7485
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7657
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7242
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7608
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5187
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3322
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1708
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
556
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.