Link to home
Start Free TrialLog in
Avatar of rwallacej
rwallacej

asked on

Typed dataset select

Hi

I have typed dataset. Created this with XSD in VS 2010, called ProductionData.  Note the data is not from a database, it is a strongly typed.  

To bind it to a gridview on form I do this:

   Dim ds = Me.ProductionData
   DataGridView1.DataSource = ds

This binds all the fields. I'd like to bind only some e.g. Field1, Field2, Field3

Is there a "Select" statement one can do to only select a few fields?

Thanks in advance
Avatar of RameshS
RameshS
Flag of India image

If you are not using  template columns in the GridView and AutoGenerateColumns is set to true, The gridview will display all the column of the dataset. If you want to display only specific columns, you can hide the unwanted columns  using the following statement

GridView.Columns[3].Visible = false;

If you are  using bound and template columns in GridView and AutoGenerateColumns is set to false, the GridView will display only those bound columns though the DataSet has many columns.
Avatar of rwallacej
rwallacej

ASKER

hi,

I'd like to keep the Gridview AutoGenerateColumns at True, and do a SELECT statement on the dataset (I presume there is a way to do this?)

thanks
ASKER CERTIFIED SOLUTION
Avatar of RameshS
RameshS
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks for more info

I see there is a .Select function on the custom dataset


Me.ProductionData.Select (.......)

can this be used to select only particular columns, and so not have to recreate table?

The Select method can be used to filter rows not columns. It wil return array of DataRows based on the condition given.

The DataSet/DataTable does not have a built-in feature to filter columns.
thank-you for help