Click here to Skip to main content
15,566,866 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

1 solution

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.
 
Share this answer
 
Comments
Zain -Ul- Arifeen 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900