Solved

How do I fill DataGrid with values on runtime

Posted on 2008-10-03
6
306 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now