We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

StyleInfo.CellValueType

Using a databound grid, I create columns on the fly. I then bind the grid. If I do _not_ set the StyleInfo.Format, the grid correctly sets the StyleInfo.CellValueType. At runtime, setting the StyleInfo.Format and re-applying it to the grid: DataBoundGrid.Binder.InternalColumns.Clear(); . . Build and Add DataBoundColumns; . . DataBoundGrid.Binder.InitializeColumns(); The cell data displays the new format correctly but the StyleInfo.CellValueType is blank. I need know the StyleInfo.CellValueType.

1 Reply

AD Administrator Syncfusion Team December 23, 2002 06:33 PM UTC

The GridDataBoundGrid only sets the StyleInfo properties if you have not any of the StyleInfo properties. This avoids the initialization code stepping on settings that you set. Here is the code segment from the _InitGridColumn method in our source.
void _InitGridColumn(GridBoundColumn gcs, PropertyDescriptor pd) 
{
	bool autoInitCellType = GridModelDataBinder.AutoInitCellTypes;
	gcs.PropertyDescriptor = pd;
	Type type = pd.PropertyType;
	if (gcs.StyleInfo.IsEmpty)
	{
		gcs.StyleInfo.CellValueType = pd.PropertyType;
		if (type.Equals(typeof(Boolean)))
		{
			...
So, if you set any properties in the StyleInfo, the CellValueType is not set. One thing you could try is to postpone setting the Format property until after the call to Binder.Initialize columns to see if that will allow the CellValueType to be set by the initialization. Another option would be for you to explicitly set the CellValueType at the same point that you set the Format.

Loader.
Live Chat Icon For mobile
Up arrow icon