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
910
Number of Columns not staying in sync with DataTable.
posted

I have a DataTable that I create on the fly, and orginally I put 10 columns in it and it binds to the datagrid with the DataSource property.

However, the user than has the option to increase or decrese the column, when the user selects to increase the column count greater than the original column count ( like going from 10 to 15), I can create the new DataTable and increase the columns in it, but when I bind the new DataTable to the DataGrid, I only get the first 10 columns.  The grid seems to ignore the other 5 columns.

The data in the first 10 columns is updated to the new DataTables data, but for some reason it wont increase the number of columns past the orginal amount.

My binding is as simple as

this.DataGrid.DataSource = null;

this.DataGrid.DataSource = dataTable.Rows;

Anyone seen this or know how I can resolve this ?

Thanks

DK

Parents
  • 2070
    posted

     Hi DK,

     

    I just tried this out and I can't reproduce the issue. Maybe it's an issue that was fixed recently or something specific to your sample that's causing it. One thing you can try is clear the FieldLayouts collection on the data grid right before setting the data source to the new table. This should cause the data grid to recreate the field layouts based on the new data source and include all the columns.

     

    Hope this helps, 

    Sandip 

Reply Children