Specify bind columns

CreateAutoGenratedColumns() binds all the columns in the datasource. It’s not clear to me how I would bind specific columns in the datasource. Is there an example some where?

Hi,

Thanks for considering Aspose.

Well, Worksheet.CreateAutoGenratedColumns() method generates only the bound columns which you have specified in the data source. You may try to create a dataset to fill your required data from the source. Or... when you open the Worksheet Collection Editor after creating your dataset object and set the datasource and datamember to the dataset object and source table, the BindColumns collection will show all the fields based on the data source, now you can remove your required fields to exclude it from the list. For further ref, please check the source code of online demos specially Data Binding demos:

Thank you.

I also need a solution to this problem.

I can programatically add a column. I can set the datasource for the worksheet. I can rebind the sheet.

How do i manually set the dataname value for a column i have created?

I can't use the CreateAutoGenratedColumns as the grid only contains a subset of the columns in the datasource.

Is there a way to programmatically create a databound column?

Thanks

Gavin

Hi Gavin,

Well, the bound columns are those columns which are based on the data source related to the data table fields. I think you may try to create / fill a datatable at runtime with your specified fields, you may add, remove your required fields in it and then use WebWorksheet.DataSource to set it to the datatable before you bind the worksheet using Worksheet.DataBind method. And CreateAutoGenratedColumns method only fills the fields data (from the data source table) on the worksheet. Well, I still do not sure about your need. Could you try to elaborate it.

Thank you.

Hi there

I am trying to programatically create a grid.

So i create a new worksheet, add a few columns, set the various collumn display properties all no problem.

Now i want to fill the grid with data from the database. I already have a dataset created from a dataadapter availabe to me containing lets say 30 fields. I want to display 10 of these fields in the grid, the rest get displayed on the screen somewhere else.

Challange is to specify the equilivant of a "DataField" property for the column, so when i bund the dataset to the grid, it populates the 10 columns defined.

I know i can create a second dataset (datatable) with the specific 10 fields only for the grid, but this is already available in the main dataset.

So my question, is this possible? Can i not say column(6) is datafield bla. Now go bind.

Any advice is appreciated.

Gavin