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
210
How To Find Errors With Column Binding
posted

For many reasons, I dynamically build my FieldLayout in procedural code and keep the contents in a database.  This allows the users to define HeaderText, for example.

But in some cases, if the user has mispelled the ColumnName in the Database or added a ColumnName that doesn't exist, my entire FieldLayout is ignored and it defaults to just showing the columns automatically. 

So is there anyway to tell if there is a binding error generated (if this happens) when I set the binding source of the datagrid so that I know that column defined in code is not correct?  I am getting no errors generated from the program, but it simply doesn't show it.  And I have had this before.  As soon as I find the columnname spelled wrong and correct it, it all works.  But sometimes when I have 100 columns, it takes a long to to compare the text.  So I am just wondering if there is another way to tell something didn't match up.

 

Parents
No Data
Reply
  • 69686
    posted

    Hello,

    The XamDataGrid will silently swallow your field layout and will create the correct one if yours is not. For this, you must leave the AutoGenerateFields to true. However, if your fieldlayout is correct, then the XamDataGrid will use yours.

    So, to detect this, you can handle the FieldLayoutInitialized event and check the count of the Fieldlayouts. Assuming that you have only one level of data, in the scenario where you have incorrect field layout, you will have two layouts in the Fieldlayouts collection. If the manual layout is correct, then the count will be one.

     

Children
No Data