DataSet / DataGrid Display Issues

papa_k

Member
Joined
Jun 1, 2009
Messages
22
Programming Experience
1-3
I am having (what I suspect is a school boy error) regarding datagrids and datasets. I have a dataset control on the form (ds1) and a datagrid (dg1). In ds1 there is a table called tbl1 and within that table there are columns col1 and col2.

I load data into ds1 which I know is present as I can use msgbox to get data row items.

I can not get the data to display in the datagrid. I have tried using the following:

VB.NET:
dg1.DataSource = ds1.Tables("tbl1")

and also using the "Choose Data Source" in the dg1 little arrow menu.

Neither work. Do I have to set anything else up with the datagrid, such as setting columns? Ideally I want the dataset to pass all the information to the datagrid.
 
Try using DataAdapter and BindingSource. Then make your gridview source = BindingSource. Check out the examples used in the vs2008 help files for VB.Net

Troy
 
hmmmmm

hmmm, something seems a little off.

Do i have to declare in the datagrid the dataset columns or will it just pick up the data?

do i need to "import" anything to my application?
 
Read the DW2 link in my signature, section Creating a Simple Data App

At the end of it you'll have a datagridview showing data and you'll have written next to no code at all. That's a Good Thing
 
I finally got this sorted - if required i can post the code.

basically i needed to create a table and add the dataset into the table, then associate that table with the datagrid.

simple when you know how - took me two whole days to work out though!!
 
Post the code? (You may get a few pointers of the correct path to follow before you get too far down a path of old/bad habits)
 
Back
Top