Hi,
Ideally it should not give you errors just because the fieldname you specified for the column does not exist in the data source.
I've verified the same here by specifying a column with non-existent fieldname and it shows up without any error, just the cells in the column are blank. (I am binding my grid to a DataTable)
In your case what I suggest is, to use one of the following two approaches;
- Either don't specify FiledName value at all. This way you will get a column without any data. This should work fine in the first place. If it not, then go for next solution.
- Since you are using the "Delete" column to place a delete button to delete a product that corresponds to the current row, you can bind that column to any other existing filed say "Product_ID". It is possible to bind multiple columns to a single field.
Further, its upto you whether you want to use this value (say pass it to the .Tag proeprty of the Button in the template, so that it can be retrieved by the Click event handler of the button in order to know which product needs to be deleted) or just discard this value.
The example xaml follows;
<!-- Data Template -->
< DataTemplate x : Key ="tmpButton">
< Button
ToolTip ="View Product Asset Distribution"
Width ="16"
Height ="16"
Template ="{StaticResource myButton }"
Tag="{xcdg : CellEditorBinding }"
/>
</ DataTemplate >
<!-- Column with modified Fieldname -->
<xcdg :Column
FieldName="Product_ID"
Title ="Delete"
CellContentTemplate="{StaticResource tmpButton}"
MaxWidth="42"
MinWidth="42"
/>
Hope it will suffice your need.
Abdullah Ansari
Senior Software Engineer
OutworX Solutions Private Limited
Everything is okay in the end. If its not okay, then its not the end.