473,405 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

how to display a single column value of a table in a DataGridView

40
hi
i need to populate a DatagridView1 with a single column values of a table.

I tried like this.

Dataset ds=new dataset();
my dataset ds retrieves and filles a single column from a table.

DataGridView1.Datasource=ds;

but grid shows empty without rows and cols when executes.

suggest me
ssknov
Dec 5 '07 #1
7 1494
nateraaaa
663 Expert 512MB
Did you call DataGridView1.DataBind() after you assigned the datasource of your DataGridView?

Nathan
Dec 5 '07 #2
ssknov
40
hi nathan,

i did so but error is prompting Error 1 "'System.Windows.Forms.Control.DataBindings' is a 'property' but is used like a 'method'"


DatGridVw1.DataSource = ds;
DatGridVw1.DataBindings();

what to do?
Dec 6 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
hi nathan,

i did so but error is prompting Error 1 "'System.Windows.Forms.Control.DataBindings' is a 'property' but is used like a 'method'"


DatGridVw1.DataSource = ds;
DatGridVw1.DataBindings();

what to do?
The Databind is a method for the gridview for Asp .Net and databindings is to assign data to a control (this is usually a field value)
So remove the databindings line.

Are you sure that your dataset is getting populated?

Try running into debug mode and check the contents of your dataset before you set the data source of the gridview.
Dec 6 '07 #4
ssknov
40
halo shashi

i checked my DataSet ds whether it gets populated , it is ok.

but datagridview shows nothing

ssk
Dec 6 '07 #5
Shashi Sadasivan
1,435 Expert 1GB
Hi ssk,
i think you cant directly assign a complete dataset to a datagridview.

you would have to to something like

datagridview.DataSource=ds.Tables[0].DefaultView;

Cheers
Dec 6 '07 #6
ssknov
40
Hi ssk,
i think you cant directly assign a complete dataset to a datagridview.

you would have to to something like

datagridview.DataSource=ds.Tables[0].DefaultView;

Cheers

thank u for ur suggestion

i ll try this


ssk
Dec 6 '07 #7
ssknov
40
Hi ssk,
i think you cant directly assign a complete dataset to a datagridview.

you would have to to something like

datagridview.DataSource=ds.Tables[0].DefaultView;

Cheers

hi
i checked through debugging , it holds the value but not comes to display
in form.......what would be???
ssk
Dec 6 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mike | last post by:
Dear group, I'm currrently investigating a bug within a piece of our software whereby if a DataGridView (bound directly to a DataTable) is ordered by column headers (containing lookup combo...
2
by: Ivan | last post by:
I have a class Foo which have two property. I have a thread that do some process and update class Foo int B. I have a datagridview on main form. this datagridview data source to this class Foo and...
3
by: finleeds | last post by:
hi all I m using the visual studio designer to create 1 Dataset with 1 table with 3 columns : Id, Name, Birthday. Once this done, still with the designer, I m creating a datagridview and...
0
by: krigare | last post by:
There maybe a better way of doing this but I am attempting to display a list of objects and their respective properties using a datagridview. The object class is straight forward with several...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.