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

Binding with ComboBoxColumn

1 Answer 89 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Vamshi
Top achievements
Rank 1
Vamshi asked on 08 May 2012, 03:36 PM
I have a GridView that has a few ComboBoxColumns. The GridView is bound to a collection of objects. The comboboxcolumns are all bound to their respective collection of objects and their selectedvalue is set to a property of the gridview's source, which is as ID. The comboxcolumn binding is two-way so any changes made in the UI are updated in the object. Everything works fine. However there is something more I need to do.

Take for example one comboboxcolumn called 'Assistant Name'. The combobox in the column is bound to a collection of objects that have an 'ID' and 'Name' as properties. Now The GridView's itemssource has a property called 'AssistantID'. So the SelectedValueMemberPath is set to ID, DisplayMemeberPath is set to 'Name' and the 'DataMemberBinding' is set to 'AssistantID'. Now, for certain business needs, the itemssource object of the gridview also has a property called the 'AssistantName'. This is the name corresponding to the 'AssistantID'. I populate both these when I initially query the database. Now when the user makes change to the 'Assistant Name' column by picking another value in the combobox, the two-way binding automatically updates the 'AssistantID' property of the gridview itemssource object but does not update the 'AssistantName', which is the 'Name' value of the picked combobox item. Now, when I save these changes back to the database everything is fine, because the changes need to only contain 'AssistantID'. However, I also have to record the change for auditing purpose and for readability/simpliciy sake, we decided to store the 'AssistantName'. This however, as I mentioned above, is not updated.

Now, without doing any extra processing during save/recording-for-auditing, is there any way to pick up the comboboxcolumn changes into the 'AssistantName' property?

I hope I have explained well what I need.

Thanks!

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 09 May 2012, 08:02 AM
Hello, 

Once the 'AssistantID' is updated, you will need to manually update the 'AssistantName'. The DataMemberBinding of the column does not know about this additional property and it cannot update it internally.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Vamshi
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or