Reputation: 11971
I have a method that returns a DataSet
. This method returns a bunch of columns to do with a file that a user has uploaded. The problem is that this method is used by both the website and the WinForms and the WinForms version does not need a specific column (InternalFileName).
Currently I am binding the DataSet to a GridView
using the following code:
importFileGridView.DataSource = temp.Tables[0];
I was wondering if it is possible to place only specific columns into the GridView's DataSource
? And if so, how?
Upvotes: 0
Views: 998
Reputation:
You want to manipulate the Columns
collection of the DataGridView
. The examples in the link should give you exactly what you're looking for.
Upvotes: 0
Reputation: 1647
You could return only the columns you need in your SQL statement that builds the data for the dataset or if you need all the data for other screens, then turn auto generate columns off on the DataGridView and add the columns manually - making sure they exist in the returned data.
Upvotes: 2
Reputation: 13960
Look at this example of how to set columns properties at runtime: http://geekswithblogs.net/michelotti/archive/2006/03/30/73896.aspx Best regards
Upvotes: 0