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

[Solved] How to get DataMemberBinding column name

1 Answer 190 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.
Berthold
Top achievements
Rank 1
Berthold asked on 01 Nov 2010, 09:49 AM
Hi, 

I want to use a ContextMenu to get the visible DataColumn and the underlying column name (not the Header!)
Since I only want the visible columns, I can not get the names from DomainDataSource (which is the data provider). 

Exp.:
<telerik:GridViewDataColumn DateMemberBinding="{Binding ColName}" Header="ColTitle"/>

How to get "ColName" ?

Thanks
Berthold

1 Answer, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 01 Nov 2010, 09:58 AM
Hello Berthold,

 You can get the binding paths for all visible data columns like so:
var names = from c in this.myGridView.Columns.OfType<GridViewBoundColumnBase>().
            Where(c => c.IsVisible).Select(c => c.DataMemberBinding.Path.Path);

Or you can also omit the Select part to get the columns themselves and then later on get the column's data property name throug the DataMemberBinding.Path.Path property.

All the best,
Yavor Georgiev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Berthold
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Share this question
or