Monday, July 09, 2012 2:11 PM
DataSet ds = new DataSet(); DataTable dt = new DataTable(); ds.Tables.Add(dt); OleDbDataAdapter dd = new OleDbDataAdapter(); dd = new OleDbDataAdapter("Select * From Jet", dbConn); dd.Fill(dt); dataGridView1.DataSource = dt.DefaultView; dbConn.Close();
I have this data set to display my whole table onto my Ms Acess database table
Now i need your help in displaying only two columns of my table in my grideview. e.g. I have (File_sed), (Names), (surname) ......n more and now i want to diplay only (File_seq), (Name)
Monday, July 09, 2012 4:02 PM
You need to set AutoGenerateColumns to false on the GridView. Then add the columns manually for the ones you want displayed and set their properties for their header text and the databinding to the columns in the table.
Tuesday, July 10, 2012 8:08 AM
okay , this is not a web app but i can relate to what you saying
i get you
Wednesday, July 11, 2012 9:49 AMModerator
"displaying only two columns of my table in my grideview"
You can just hide the columns you don't want to show.
eg: this.dataGridView1.Columns["surname"].Visible = false; // hide "surname" column
And you can check this article: How to: Hide Columns in the Windows Forms DataGridView Control.
Have a nice day.
Bob Shen [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Hefff Thursday, July 12, 2012 7:23 AM
Thursday, July 12, 2012 7:23 AMthat was just super, thanks alot