Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How do I fill DataGrid with values on runtime

Posted on 2008-10-03
6
308 Views
Last Modified: 2013-11-17
I am trying to compile a sample application that is a datagrid which is connected to a dataset (which is a table in database).

I've connected all the elements but failed to fill in data in the grid (from the table) --
How do I accomplish that?
0
Comment
Question by:amitbueno
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:the_bachelor
ID: 22634092
I think your question is rather vague as it does not tell which technique your're employing to "connect" your stuff.
A little code will be welcome here...
0
 

Author Comment

by:amitbueno
ID: 22634188
Hard so post a code,. because all I did was in design time.
In delphi connecting a datagrid to database done visually,. I thought that in vs vb as well... (though I probably was mistaken)

In design time, I created a wince application, put a datagrid on the fom. Created a database with a table...
Assigned DataSet,. And databinding, and created a datamember which is the table from the database,. in the dataset I specified the database, and datamember.

Now I would like to display a grid with the table data in it.
0
 
LVL 7

Expert Comment

by:the_bachelor
ID: 22634658
Sorry I for some odd reason thought you was using ASP.NET. Sounds like u're building a Windows app.
Question for you: Does the database itself has data in it?

Here is what i did, might help you. I'm using VS 2008.
So I dragged a DataGridview on my form, added a Project Datasource as prompted, Selected a table and Boom I got data bound the grid...
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

Author Comment

by:amitbueno
ID: 22634831
I am using .NET Compact Framework.
It doesn't have the DataGridView only DataGrid... But I think it is the same as the datagridview.
I selected a database and a table in the DataSetBindingSource, and assigned the Grid to it.

If that is enough why don't I see the data when running the application?
The database is with data in it of course...
0
 
LVL 15

Accepted Solution

by:
JackOfPH earned 50 total points
ID: 22639043
Set the datasource of the datagrid in the form load event of the form.

For example put this code in the Form Load Event:

Datagrid1.Datasource = Dataset.Table("YourTable")
0
 

Author Comment

by:amitbueno
ID: 22640060
A little progress...

I've designed in design time, the datasource to point to the table,. Yet when running the code it raises an exception saying that the table doesn't exist (although I've designed a reference to it)
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

828 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