In this solved challenge, I had a GridView on my C# Web Application that was dynamically creating columns based on user selections. In the general case, everything was working without any problems. The potential column names were listed in the database, which were selectable from a checkbox list.
One day, I got reports that the page was breaking (javascript error), but not blowing up completely. I narrowed down to the fact that one of the potential column names added to the database included a period (or dot). During the debugging phase, I found the following error, where in fact the column name should have been called ‘12.5′.
DataBinding: ‘System.Data.DataRowView’ does not contain a property with the name ‘12′.
This was then causing the code that at runtime creates columns to error. The column seems to be successfully created, but the column name was only displaying as ‘12′ as opposed to ‘12.5′. As it turns out, the Eval function accepts a pattern, which the period (or dot) is assigned different meaning.
hl.Text = DataBinder.Eval(row.DataItem, columnName).ToString();
Through searching the MSDN libraries and the internet, I came across a similar solution where we assign the hyperlink via a different function. The GetPropertyValue function appears not to use a pattern search and instead searches for the string exactly as is passed in the function.
hl.Text = DataBinder.GetPropertyValue(row.DataItem, columnName).ToString();
Therefore, this was a solution to my problem. Through other various web developer forums and sites, I have also found that this problem applies not only to the period (or dot), but also to other special characters of the pattern. I believe dot means wildcard.
RSS Feed
Posted in
Tags: 
