Solved

Create a Disconnected Dataset bound to a Datagrid

Posted on 2004-10-12
4
311 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 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

773 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