Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
how to make a dtatgridview manually or from their property(collection) and load data in the datagridview from the database.
 
Any one Can Help Me
Posted 17-Nov-12 20:07pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can populate datagridview by two way.
 
First you can create & map column in design view.
datagridview -> property -> columns -> Add column as your requirement (by defining field type, Column Header & others properties).
 
*Dont forget to mention DataPropertyName. It will be the field name of database column.
 
For populate Data:
datagridview.DataSource=datasource
 
In datasource you can specify table or dataset in which you fatch data from database server.
 

Second you can directly populate by datagridview.DataSource=table/datasource
Here column name of datagridview will be column name of table(database table).
 

Here is onother important things is AutoGenerateColumns:
 
If you specify datagridview.AutoGenerateColumns = true it means datagridview automatically generate column as per provided table (require for second option).
If you define all columns in design mode and don't want to hide extra field then set it to false (for first option).
 
by default it is true.
  Permalink  
Comments
Zain -Ul- Arifeen at 19-Nov-12 4:57am
   
how to specify table or dataset in which you fatch data from database server in th datasource.
sir, i am the beginner of this language.
plz,plz,plz, help me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 /\jmot 230
1 Zoltán Zörgő 210
2 CHill60 145
3 Peter Leow 145
4 Sergey Alexandrovich Kryukov 125
0 Sergey Alexandrovich Kryukov 9,353
1 OriginalGriff 6,881
2 Peter Leow 4,577
3 Zoltán Zörgő 4,129
4 Richard MacCutchan 2,882


Advertise | Privacy | Mobile
Web01 | 2.8.150129.1 | Last Updated 18 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100