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
975
Switching UltraGrid Datasource at runtime
posted

I'm getting flakey behavior when, at runtime, I change my datasource from a dataset to a dataViewManager.  (The grid has 2 bands.)

For testing,  I put two buttons on my form to switch between the dataset and the dataViewManager.  It seems to sometimes work and sometimes not.  Sometimes, after clicking one of the buttons and nothing seems to happen, I'll mess around with the grid, say double-clicking on a row selector, and then all of a sudden,  the data corresponding to the selected datasource will appear. 

The code I use to switch the datasource :

myGrid.SetDataBinding(myViewManager, "");  or  myGrid.SetDataBinding(_myDataSet, ""); 

ugObjectWorkList.Refresh();  // I do this but understand it shouldn't be necessary.

Here's the code to create the dataview.

(myBand_1_Table is one of two tables in the dataset, along with a dataRelation.)

/////////////////////////////////////////////////////////////////////////////////////// 

String myTable;
foreach (DataViewSetting myDVS in viewManager.DataViewSettings)
{
 myTable = myDVS.Table.ToString();
 if (myTable == "myBand_1_Table")
 {
      myDVS.RowFilter = strFilter;
 }
}
ugObjectWorkList.SetDataBinding(viewManager, "");
ugObjectWorkList.Refresh();

/////////////////////////////////////////////////////////////////////////////////////// 

 Because this seems to work sometimes, I figure I've not done something fundamentally wrong, say with the rowfilter string or the configuration of myDataSet or viewManager.

(And I just replied to another post asking how to do this, claiming success.  I'll have to reply agian when/if, I get this working smoothly.  )

Thanks for any ideas;

 

Bill

Parents
No Data
Reply
  • 975
    posted

    Ok, I ran across this suggestion here in the forums: Before changing the datasource,

    myGrid.DataSource = null;

    I'd tried that but early on, while testing other ideas at the same time.  Not I have the proper combination. 

    Thanks,

    Bill

Children