[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Create a Disconnected Dataset bound to a Datagrid

Posted on 2004-10-12
4
Medium Priority
?
319 Views
Last Modified: 2010-04-23
I am forced to gather information from methods of a COM object, and display it in a datagrid. Of course the big problem is - NO Database! Boy is it hard to find help on this one. I thought I would ask you gurus.

How to I manually create and populate a dataset table & bind it to a noneditable datagrid (if that matters)? I am amazed at how difficult this seems. I have found other solutions to populate the datagrid, but they all have little quirks. I was told that datagrids should really be bound to datsets. Any ideas?
0
Comment
Question by:JeepGeekin
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12287578
Hi, Try this:

 Dim ds As New DataSet

   Private Sub FilldsManually_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

      Dim dt As New DataTable
      Dim dr As DataRow

      'Create dataTable
      dt.Columns.Add("MyFirstColumn")
      dt.Columns.Add("MySecondColumn")

      'Create DataRow
      dr = dt.NewRow
      dr("MyFirstColumn") = "Hello"
      dr("MySecondColumn") = "Bye"
      dt.Rows.Add(dr)

      ds.Tables.Add(dt)

      DataGrid1.DataSource = ds

   End Sub

   Private Sub AddRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
      Dim dr As DataRow


      'Create DataRow
      dr = ds.Tables(0).NewRow
      dr("MyFirstColumn") = "Hello"
      dr("MySecondColumn") = "Bye"
      ds.Tables(0).Rows.Add(dr)

   End Sub
0
 

Author Comment

by:JeepGeekin
ID: 12288172
Oh sure. Make it seem that simple!
Looks like it works, but I am getting something new in my datagrid I have not seen before.

It shows up with just a plus sign. When I click on it, it shows me "Table1". When I click on Table 1, the data fills out the datagrid. Any idea why it is doing this?
0
 
LVL 10

Accepted Solution

by:
Hans Langer earned 2000 total points
ID: 12288248
sorry, I forget this line:

DataGrid1.DataSource = ds
DataGrid1.DataMember = ds.Tables(0).TableName.ToString
0
 

Author Comment

by:JeepGeekin
ID: 12288265
Excellent!
I actually came back out to tell you I figured it out (with my tail between my legs). Thanks for your help. This is exactly what I needed!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month19 days, 22 hours left to enroll

872 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