Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1960
Binding a DataSet to a grid with unbounded, run-time generated columns
posted

Hello,

I'm trying to bind a DataSet to a grid containg colunms generated at runtime. This is what I'm doing:

First I set DisplayLayout.AutGenerateColumns = false 

On the Load event of my main page I initailize the grid by adding the columns I want. Here's an example: 

UltraWebGrid1.Bands[0].Columns.Clear();

UltraGridColumn gridColumn = new UltraGridColumn(true);

gridColumn.Key = "FirstName";

gridColumn.Header.Caption = "First Name";

UltraWebGrid1.Bands[0].Columns.Add(gridColumn);

Then I call the DataBind() method on my grid.

In the DataBinding event handler I set the datasource:

UltraWebGrid1.DataSource = generateDataSet();

The generateDataset() method returns a DataSet with one DataTable containing 20 DataRows with only one column called "FirstName", which is a string. I'm setting the value of each column on each row to some sample names.

When the grid is rendered I can see there are 20 rows, but there's nothing inside de cells.

I placed some code inside the InitializeRow event handler, and I can see that the UltraGridRow objects have null content on the cell. The e.Data property contains the DataRow, and I can see the value of the FirstName column is not null.

What I'm I missing? Maybe the DataBind() method only works for columns where the IsBound property = true?

Any help is greatly appreciated.

Thanks