views:

128

answers:

1

Hello,

Say we data bind GridView to an ObjectDataSource control and then perform a query.

A) I realize displayed GridView fields are of type String, but does GridView also know of what type the underlying data source values are ( for particular GridView column )?

* Thus, if data source will populate GridView with bunch of integers, then these integers will have to be converted to strings, before they can be displayed in GridView. Which control will perform the conversion, GridView or ObjectDataSource/SqlDataSource control?

B) Regardless of whether GridView or ObjectDataSource performs a conversion, how is that conversion performed? Simply by calling ToString() on an object?

thanx

+1  A: 

Heres the code from the bound column control (via reflector):

 if (this.formatting.Length == 0)
 {
     return dataValue.ToString();
 }
 return string.Format(CultureInfo.CurrentCulture, this.formatting, new object[] { dataValue });
  • this.formatting: The format string, is what Henk has explained.
  • dataValue: An object variable which is the value of the bound property
Brendan Kowitz