how to get cell updates when datagrid binding to dataset with dynamic columns

Oct 21, 2009 at 1:44 PM

how to get cell updates when datagrid binding to dataset with dynamic columns

when doing something like below, how can we get updates to the objects when the value is updated in the gui?

Is there another way to dynamically build a datagrid with dynamic number of columns/data?

 

    public DataView getDataView()
    {
   var rows = getRows();
      foreach (var bb in rows)
      {
        DataRow row = dataTable.NewRow();
        foreach (var cc in bb.fields)
        {
          row[cc.name] = cc.value;
        }

        dataTable.Rows.Add(row);
      } 
 
      var view = dataTable.DataSet.DefaultViewManager.CreateDataView(dataTable);
   return view;
    }
  
  
  
    <StackPanel>
      <!--
      <wpfT:DataGrid
        Name="dataGrid1"
        ItemsSource="{Binding}"
        AutoGenerateColumns="True"
      >
      </wpfT:DataGrid>
      -->
      <!--
      -->
      <StackPanel.Resources>
        <ObjectDataProvider
          x:Key="gridDataProvider"
          ObjectType="{x:Type local:DataHandle}"
        >
        </ObjectDataProvider>
        <ObjectDataProvider x:Key="gridData"
          ObjectInstance="{StaticResource gridDataProvider}"
          MethodName="getDataView"
        >         
        </ObjectDataProvider>
      </StackPanel.Resources>
      <wpfT:DataGrid
        Name="dataGrid1"
        ItemsSource="{Binding}"
        AutoGenerateColumns="True"
        DataContext="{Binding Source={StaticResource gridData}}"
      >
      </wpfT:DataGrid>
    </StackPanel>