Data set to display Individual Columns from Ms acess Using C#
-
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)
All Replies
-
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.
http://www.codeproject.com/Articles/13462/How-to-create-template-columns-dynamically-in-a-gr
HTH
Ciaran
http://www.wannabedeveloper.com -
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
Thanks alot
-
Wednesday, July 11, 2012 9:49 AMModerator
Hi Siphambo,
"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

