G
Guest
I have a custom grid control and I'm stuck on an issue in the data binding.
Using a method similar to the DataGridColumnStyles class, I have a column
style class that allows you to map the bound datasource fields to the grid
columns.
I've added a Format property which will take a format string such as "{0:C}"
which will then convert the underlying data to a currency string.
This works very nicely. The problem is when the user goes in and edits data.
Let's say that a column has the above currency format string and the data in
the cell is $4.45
If the user changes the value, I need to then update the data source. I need
to handle the situation where the user puts in either $4.50 or 4.50 and be
able to properly convert it back to the underlying type.
Is there an easy way to do this without doing a huge case statement for all
the different data types?
The underlying data can, of course, be of any type. In the grid it's
represented as a string. All I have is the format string to know about
formatting. I'd rather not have to parse the format string to figure out how
to parse the underlying data. Is there some way I can use it to do the
parsing?
Thanks.
Pete
Using a method similar to the DataGridColumnStyles class, I have a column
style class that allows you to map the bound datasource fields to the grid
columns.
I've added a Format property which will take a format string such as "{0:C}"
which will then convert the underlying data to a currency string.
This works very nicely. The problem is when the user goes in and edits data.
Let's say that a column has the above currency format string and the data in
the cell is $4.45
If the user changes the value, I need to then update the data source. I need
to handle the situation where the user puts in either $4.50 or 4.50 and be
able to properly convert it back to the underlying type.
Is there an easy way to do this without doing a huge case statement for all
the different data types?
The underlying data can, of course, be of any type. In the grid it's
represented as a string. All I have is the format string to know about
formatting. I'd rather not have to parse the format string to figure out how
to parse the underlying data. Is there some way I can use it to do the
parsing?
Thanks.
Pete