We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

how to get s specific column from a data source

Hi there,
How do I get a specific column from a table in a bound data source?

DataSet ds;
...

this.ds.Table["myTable"]....?????

grid.DataSource = [just the column I want];

Thanks
Dimitri

6 Replies

AD Administrator Syncfusion Team December 5, 2006 06:48 PM UTC

I should add that my data is coming from XML...

myDataSource.ReadXML("file");


>Hi there,
How do I get a specific column from a table in a bound data source?

DataSet ds;
...

this.ds.Table["myTable"]....?????

grid.DataSource = [just the column I want];

Thanks
Dimitri


AD Administrator Syncfusion Team December 5, 2006 07:44 PM UTC

Any help on this would be great, thanks.

>I should add that my data is coming from XML...

myDataSource.ReadXML("file");


>Hi there,
How do I get a specific column from a table in a bound data source?

DataSet ds;
...

this.ds.Table["myTable"]....?????

grid.DataSource = [just the column I want];

Thanks
Dimitri


AD Administrator Syncfusion Team December 6, 2006 04:35 AM UTC

Hi Dimitri,

Use the GridBoundColumns property to manages the bound columns in a GridDataBoundGrid. Here is a code snippet.

//Clear the All columns bound to grid...
this.gridDataBoundGrid1.GridBoundColumns.Clear();

//Add the new column to display in a grid.
GridBoundColumn EmpName = new GridBoundColumn();
EmpName.MappingName = "ColumnName";
this.gridDataBoundGrid1.GridBoundColumns.Add(EmpName);

this.gridDataBoundGrid1.DataSource = ds.Tables[0];

Here is a sample.
GDBGSingleColumn.zip

Best Regards,
Haneef


AD Administrator Syncfusion Team December 6, 2006 05:34 PM UTC

Thank you Haneef - that works, except that it doesn't let me load combo box cells from yet another DataSource. How can I do that?


AD Administrator Syncfusion Team December 7, 2006 04:33 AM UTC

Hi Dimitri,

Try setting the StyleInfo.CellType property of the BoundColumn to "ComboBox" in a grid. Here is a code snippet.

GridBoundColumn EmpName = new GridBoundColumn();
EmpName.MappingName = "EmpName";
EmpName.HeaderText = "EmployeeName";
EmpName.StyleInfo.DataSource = GetComboTable();

//For setting the Combobox column with datasource as Datatable.
EmpName.StyleInfo.CellType = "ComboBox";
EmpName.StyleInfo.ValueMember = "ComboEmpName";
EmpName.StyleInfo.DisplayMember = "ComboEmpName";

this.gridDataBoundGrid1.GridBoundColumns.Add(EmpName);

Here is a modified sample.
GDBGModifiedsample.zip

Best Regards,
Haneef


AD Administrator Syncfusion Team December 7, 2006 02:38 PM UTC

Thanks!
I will take a look.

Loader.
Live Chat Icon For mobile
Up arrow icon