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

Controlling visibility / title of columns

4 Answers 85 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.
Masoud
Top achievements
Rank 1
Masoud asked on 29 Dec 2011, 07:05 PM
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

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 30 Dec 2011, 07:51 AM
Hello,

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
0
Accepted
Maya
Telerik team
answered on 30 Dec 2011, 01:44 PM
Hi,

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!

Tags
GridView
Asked by
Masoud
Top achievements
Rank 1
Answers by
Maya
Telerik team
Masoud
Top achievements
Rank 1
Share this question
or