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
345
Field Labels not updating when changing datasource
posted

Hi,

I'm using a datatable as the datasource for a xamDatagrid (in a mvvm scenario, so I dont have direct access to the view from the viewmodel side)

I have found several issues when using databinding with the grid:

1) The captions of the datatable aren't being used as the labels (I have already posted about this issue elsewhere and it is being investigated - its not the main concern of this post, but I thought the issues may just be related). It does work if you use the following syntax: dgContacts.DataSource = dt.AsEnumerable(); but since I'm using mvvm I cant interact with the grid directly with the viewmodel http://news.infragistics.com/forums/t/25645.aspx

2) Changing the caption of the column in the datatable does not update the field label in the grid. This happens even when using a "normal" wpf app and using the dt.AsEnumerable syntax.

Here is a bit of sample code (not using mvvm in the sample)

private void LoadData()
{
dt = new DataTable();
                dt.Columns.Add(new DataColumn { ColumnName = "ContactID", Caption = "Contact ID" });
                dt.Columns.Add(new DataColumn { ColumnName = "ContactName", Caption = "Contact Name" });
                dt.Columns.Add(new DataColumn { ColumnName = "ContactSurname", Caption = "Contact Surname" });

                DataRow dr = dt.NewRow();
                dr[0] = "1";
                dr[1] = "Jacques";
                dr[2] = "Doubell";
                dt.Rows.Add(dr);

                dgContacts.DataSource = dt.AsEnumerable();
}

private void button1_Click(object sender, RoutedEventArgs e)
        {
            dt.Columns[0].Caption = "New Caption";          
        }

Any help would be appreciated, thanks!

 

 

  • 9694
    posted

    Hello,

    I apologize that this post was not answered. We are making the effort to ensure all posts are addressed by an Infragistics expert. I was wondering if you still need our assistance in this matter. Have tried using the latest version as that should have corrected any updating issues concerning the grid and data binding.

    Sincerely,