sharepointformattingspgridview

What is the correct way to format SPGridView values being displayed?


Problem

As we know, SharePoint saves data in database in plain text. Some fields even have concatenated strings like <id>;#<value> for user fields. Percents are saved as doubles (1.00000000000000 for 100%) and etc.

Ofcourse, I want to display data as they are displayed in lists.

What should I do?

Should I use derived SPBoundField to format values (Which I actually did and it works fine until you want to filter (probably SPBoundField won't format me values because i use ObjectDataSource not list and with reflector I saw if there are SPListItems in datasource, then it formats correctly. Not my case)

alt text http://img199.imageshack.us/img199/2797/ss20090820110331.png

Or must I loop through all the DataTable and format each row accordingly?

What are Your techniques?

Thank you.


Solution

  • After all, i did have not know any other solution to loop through DataTable rows and format them accordingly.

    If your SPGridView's data source is list, try out SPBoundField.