locked
WTF WPF? Datagrid Has Items (62 of them) But No Columns? RRS feed

  • Question

  • Here is the situation:

    DataGrid indicates it has items, but no columns, when ItemsSource set to DataTable driven from SQL stored procedure combining fields from two database tables, of which several fields (the ones from the second table) are null, because they have not yet been populated.

    DataTable mapset = GFIData.getFareMap(forThisDate, GFIData.DETERMINANT.FALSE);

    // from the mapset

    Console.WriteLine("mapset.Rows.Count: " + mapset.Rows.Count);  = 62

    Console.WriteLine("mapset.Columns.Count: " + mapset.Columns.Count); = 17

    // assign data to datagrid

    dgdFareTypes.ItemsSource = mapset.DefaultView;

    // from the datagrid

    Console.WriteLine("Items: " + dgdFareTypes.Items.Count); = 62

    Console.WriteLine("Cols: " + dgdFareTypes.Columns.Count); = 0

    WHEN looking into the DataGrid object, dgdFareTypes, the data is there:

    under NonPublic >> EditableItems >> ResultsView

    The individual row contents are visible from here:

    NonPublic >> EditableItems >> ResultsView >> [0] (the first row) >> Row >> ItemArray



    • Edited by smacklby48 Monday, November 26, 2012 5:14 PM additional clarification
    Monday, November 26, 2012 4:46 PM