This is a migrated thread and some comments may be shown as answers.

AutoGenerateColumns on a SQL_Variant Type

2 Answers 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 01 Feb 2011, 12:33 PM
Hi,

I have noticed that when AutoGenerateColumns="true", a sql_variant field returned as the datasource will not appear in the grid. However, if you create your columns programmatically or in the aspx page (AutoGenerateColumns="false"), and set the DataField property to the sql_variant field name, it works.

Can anyone at Telerik explain why this is, and if there is a workaround to get sql_variant fields to show up as columns when using AutoGenerateColumns?

As of now, my workaround is to cast the sql_variant as another datatype (in my case an INT) in the sql procedure that returns the dataset. However, I believe the radgrid should be able to handle this on its own, just as it handles it if you are not using AutoGenerateColumns, and set a column's DataField property to the sql_variant field.

Thanks

Daniel

2 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 04 Feb 2011, 10:28 AM
Hi Daniel,

Unfortunately this type is not supported for autogenerated columns in RadGrid because it is too generic. Internally sql_variant is converted to System.Object but it cannot be set as a DataType for bound column. In the case when you do not have autogenerated columns the GridBoundColumn handles correctly the type because by default every data bound to it is converted to string.
One workaround is to stay with autogenerated columns but explicitly create a column that is bound to this field.

Regards,
Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Daniel
Top achievements
Rank 1
answered on 04 Feb 2011, 11:10 AM
Hi -- Thanks for the response. I think the behavior expected is that (just as when a sql_variant is bound to a column) in AutoGenerate mode, a sql_variant column should be handled as as string. This would be the expected behavior of any developer.

Perhaps it is worth changing the behavior to match what I am saying.

Either way thanks for your support, and I have to say, I am continually impressed by the high level of service Telerik provides. I even got a call back!

Thanks

Daniel
Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Marin
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or