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

Setting the Binding of GridViewDataColumn throws exception

4 Answers 55 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ludovic Gerbault
Top achievements
Rank 1
Ludovic Gerbault asked on 26 Jan 2010, 09:32 AM
I have a source collection made of a lightweight datatable.

When I create manually from code behind the columns of the grid, I also bind each one of them to the DataColumn of the DataTable which has the same name.

The thing is, how come this line :

GridViewDataColumn col3 = new GridViewDataColumn() { Header = col.ColumnName.ToString().Replace('_', ' '), DataType = typeof(Decimal), DataMemberBinding = new Binding() { Path = new PropertyPath(col.ColumnName)}, CellStyle = this.Resources["gridviewCellStyle"as Style, UniqueName = col.ColumnName, TextAlignment = TextAlignment.Right, IsVisible = col.IsVisible }; 

throws an exception when col.columnName = "2009" ??

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 26 Jan 2010, 09:41 AM
Hello,

Can you verify if the col.ColumnName does not have any blank space?

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ludovic Gerbault
Top achievements
Rank 1
answered on 26 Jan 2010, 09:50 AM
No, there isn't any

Here's the stacktrace

Liaison de chemin non valide au caractère 2 de 2009
   à System.Windows.PropertyPathParser.ReadStepDescriptor(Boolean calledFromParser)
   à System.Windows.PropertyPathParser.Parse()
   à System.Windows.PropertyPath.ParsePath(String path, Boolean calledFromParser)
   à System.Windows.PropertyPath.ParsePathInternal(Boolean calledFromParser)
   à System.Windows.Data.Binding.set_Path(PropertyPath value)
   à SilverPartenaire.PartenaireGrille._wsPartenaireClient_GetOngletsContentCompleted(Object sender, GetOngletsContentCompletedEventArgs e)
   à SilverService.ApplicationService.ApplicationServiceClient.OnGetOngletsContentCompleted(Object state)
0
Vlad
Telerik team
answered on 26 Jan 2010, 10:30 AM
Hello,

I've just tried this and I've found that you cannot create Binding in Silverlight with such property name. For example:

var binding = new System.Windows.Data.Binding("1");

I've attached small application to illustrate you how to achieve this using custom column.

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ludovic Gerbault
Top achievements
Rank 1
answered on 26 Jan 2010, 10:31 AM
FYI : It raises the same exception if there are column names containing characters like ° or /
Tags
GridView
Asked by
Ludovic Gerbault
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Ludovic Gerbault
Top achievements
Rank 1
Share this question
or