This question is locked. New answers and comments are not allowed.
Hi there,
Is it possible to retrieve the name of the property that a RadGridViewColumn is bound to via DataMemberBinding? I need this information for two reasons:
- show and hide columns in a grid based on the name of the property the column is bound to.
- set the title of a column based on the name of the property the column was bound to
Thank you very much for your help
Is it possible to retrieve the name of the property that a RadGridViewColumn is bound to via DataMemberBinding? I need this information for two reasons:
- show and hide columns in a grid based on the name of the property the column is bound to.
- set the title of a column based on the name of the property the column was bound to
Thank you very much for your help
4 Answers, 1 is accepted
0
Hello,
In this case 'column" is the one which corresponding property you want to find.
All the best,
Maya
the Telerik team
You can find the name of the property as follows:
var propertyName = column.DataMemberBinding.Path.Path;
In this case 'column" is the one which corresponding property you want to find.
All the best,
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Masoud
Top achievements
Rank 1
answered on 30 Dec 2011, 01:09 PM
Hello,
DataMemberBinding is a property of GridViewBoundColumnBase. The Columns collection of RadGridView exposes a collection of type GridViewColumnCollection that exposes GridViewColumn which doens't expose a DataMemberBinding. How do I get a collection of GridViewBoundColumnBase from the RadGridView? Is it possible to obtain the GridViewBoundColumnBase the maps to a GridViewColumn?
Thank you for your help!
Regards
DataMemberBinding is a property of GridViewBoundColumnBase. The Columns collection of RadGridView exposes a collection of type GridViewColumnCollection that exposes GridViewColumn which doens't expose a DataMemberBinding. How do I get a collection of GridViewBoundColumnBase from the RadGridView? Is it possible to obtain the GridViewBoundColumnBase the maps to a GridViewColumn?
Thank you for your help!
Regards
0
Accepted
Hi,
What is the type of columns that you are working with ? Do you define unbound columns ?
Kind regards,
Maya
the Telerik team
Generally, you can cast each of the columns in Columns collection of RadGridView to its corresponding type. For example:
GridViewColumnCollection columns = this.clubsGrid.Columns;
var firstColumnPropertyName = (columns[0] as GridViewDataColumn).DataMemberBinding.Path.Path;
What is the type of columns that you are working with ? Do you define unbound columns ?
Kind regards,
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Masoud
Top achievements
Rank 1
answered on 30 Dec 2011, 06:57 PM
Hi,
thank you for the information! I am using BoundColumns, and am now able to retrieve the information I need!
Best regards!
thank you for the information! I am using BoundColumns, and am now able to retrieve the information I need!
Best regards!