StrataFrame Forum

changing Datasource for Grid Control

http://forum.strataframe.net/Topic4787.aspx

By Amadneep Kirar - 11/27/2006

Hi..



i am using a Datagrid control in my application.

i am binging a datatable to grid on page load.

and on a click event of a button i am binding another datatable to grid.which i deserialize from stream.but datagird shows me the DataCoulumns and Datarows only but not the values.

i tried grid.refresh(), grid.refreshdatasource() but problem still exists.



when i bound the same datatable i deserialized from stream with no datasource bound to grid then am values are displayed on grid.



please help.



The code is as follows.



dtOffers = b.Deserialize(fileStream) as DataTable;

dtOffers.RemotingFormat = SerializationFormat.Binary;

if (dtOffers != null)

{

gridOffer.BeginUpdate();

gridOffer.DataSource = null;

gridOffer.DataSource = dtOffers;

gridOffer.RefreshDataSource();

gridOffer.EndUpdate();

}
By StrataFrame Team - 11/28/2006

Are you binding to a business object or directly to a DataTable?

It could be that the new data table does not have the same columns as the first DataTable and therefore, none of the data is showing up.  You might try setting the AutoGenerateColumns property to True before you set the data source.