Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a gridview. And I have to bind that gridview with database...
I want to create columns according to database items..
Posted
Updated 25-Sep-13 19:32pm
v2

Firstly SET AutoGenerateColumn=False then go for Solutions 1
 
Share this answer
 
v2
Comments
BulletVictim 26-Sep-13 2:25am    
Why set the AutoGenerateColumn=False?
I run it with AutoGenerateColumn=True and it works fine for me.
Is there some long term problem with running it like that?
indrajeet jadhav 26-Sep-13 4:14am    
AutoGenaraate Means Default columns of gridview .If you add your database table fields
in this case its shows your field columns+Default columns...If you have no issue ..then its absolutely fine..no future issues
Try using something like this

C#
conn.Open();
               DataSet ds = new DataSet();
               OleDbDataAdapter da = new OleDbDataAdapter("SELECT Columns FROM Table", conn);
               OleDbCommandBuilder cmdBldr = new OleDbCommandBuilder(da);
               da.Fill(ds, "Table");
               dgv.DataSource = ds;
               dgv.DataMember = "Table";
               conn.Close();
 
Share this answer
 

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