This is a migrated thread and some comments may be shown as answers.

UniqueName + DataMemberBinding causes binding errors

3 Answers 289 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 31 Dec 2013, 06:16 PM
Hi,

We are heavy users of the GridView control. We have run into binding errors, however, when using UniqueName and DataMemberBinding. In our grids, we bind all columns using DataMemberBinding, but we use UniqueName on some columns that are NOT for binding and instead have a custom cell template defined (e.g. place buttons in the cell). The UniqueName is used for this column so we can toggle its visibility when the user exports the grid to Excel. In this case, the code gets a reference to the grid, gets the column to disable by the UniqueName and then turns the visibility to off. After the export, it turns the visibility on.

Here's a snippet:
System.Windows.Data Error: 40 : BindingExpression path error: 'ActionColumn' property not found on 'object' ''CommunicationLogAcco_4549BD8698DC45DB0CECE67D05EB3039BC10A8BFF12C4F445B3229782B933388' (HashCode=36213804)'. BindingExpression:Path=ActionColumn; DataItem='CommunicationLogAcco_4549BD8698DC45DB0CECE67D05EB3039BC10A8BFF12C4F445B3229782B933388' (HashCode=36213804); target element is 'GridViewCell' (Name=''); target property is 'ValueChangedListener' (type 'Object')<br>System.Windows.Data Error: 40 : BindingExpression path error: 'ActionColumn' property not found on 'object' ''CommunicationLogAcco_4549BD8698DC45DB0CECE67D05EB3039BC10A8BFF12C4F445B3229782B933388' (HashCode=36213804)'. BindingExpression:Path=ActionColumn; DataItem='CommunicationLogAcco_4549BD8698DC45DB0CECE67D05EB3039BC10A8BFF12C4F445B3229782B933388' (HashCode=36213804); target element is 'ValueSetter' (Name=''); target property is 'Value' (type 'Object')


This all works fine, but the output window can have hundreds and hundreds of binding errors (one for each row in the grid!!) which hurts performance. If we remove the UniqueName it goes away, but then we can't toggle the columns on/off.

A previous post on this topic in the Silverlight forums dates from 2011 and mentions UniqueName being deprecated yet in the latest DLL it is still very much present and useful. Is there any solution for this situation? For now, we are finding the column to toggle using the header but this makes localization extremely challenging.

Steve

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 01 Jan 2014, 11:54 AM
Hello,

Basically, when you have specified UniqueName for the columns, but no DataMemberBinding is set, RadGridView tries to use columns' UniqueName as binding path. 

My suggestion is that you set and use
 Header instead of UniqueName.

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Pat
Top achievements
Rank 1
answered on 20 Nov 2015, 03:54 PM

Using header is no a viable option.    Headers define the user visible column header.   You often want it to have spaces, and symbols ($, ? etc).     Often you also want to have non-unique values so you can have the same header multiple times.    But uniquename is supposed to be unique and we use it heavily for column format storing.    

 

I am disappointed that uniquename was EVER considered to be a binding recommendation.   But if it was then it is inconvenient that you can't turn it off with an option or because the contents of the column already have a binding.

 

I guess I'll just have to add a fake binding to my columns at the column level that binds to "StupidFakeBindingBecauseOfTelerikFoolishness" which I'll add as a property to all my classes now.

0
Maya
Telerik team
answered on 23 Nov 2015, 07:33 AM
Hi Pat,

You do have a point and we've been considering a way to remove that functionality over the years, but every time the fact that we will introduce significant breaking change has stopped us. 
What might be a solution here is not to work with bound columns if there is not need for DataMemberBinding and use GridViewColumn instead. This column will not try to create a binding and no errors will be generated.


Regards,
Maya
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Steven
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Pat
Top achievements
Rank 1
Maya
Telerik team
Share this question
or