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

[Solved] Issue with Grid Columns Controls (Textbox vs RadNumeric)

1 Answer 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
SchaF
Top achievements
Rank 1
SchaF asked on 08 Jul 2013, 02:50 PM
Ive got a RadGrid that is having its datasource bound in the code behind using the NeedDatSource event. The records I get are dynamic every time as far as the columns that are coming back, which is why Im letting the grid auto generate the columns. Im using the columns later on during an update, so I need them but the issue Im facing is with the controls that are created when the rows are added. Sometimes the rows come back and the control that is created in the row is just a regular textbox, but sometimes its a RadNumeric box. This looks poor because sometimes there are values that come back that happen to only be numbers at the time, but in reality are alpha numeric, and when I go to edit them, they can throw an error that the value is too large for an int. This also looks relaly poor because when I return a value that is a number, it always displays the commas which I dont like.

My question is, in which event are the controls created and how can I force all of the controls per row cell to just be regular Textbox, not a RadNumeric or RadDecimal?

1 Answer, 1 is accepted

Sort by
0
Deyan Enchev
Telerik team
answered on 11 Jul 2013, 11:15 AM
Hello,

Currently, when using RadGrid with automatically-generated columns the data type of the column data determines the type of the editor this column will render in edit mode. You can read more on the column types and their editors here in our online help:
http://www.telerik.com/help/aspnet-ajax/grid-column-types.html

The only workaround to this behavior I can think of is a way for you to force records coming from the data source to a different type based on your goals. For example in case SQL back-end is used, you can modify you select command like this:

SelectCommand="SELECT CAST(OrderID AS varchar(50)) FROM Orders"

For more information on that topic refer to CAST and CONVERT (Transact-SQL) help section in msdn.microsoft.com

Regards,
Deyan Enchev
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
SchaF
Top achievements
Rank 1
Answers by
Deyan Enchev
Telerik team
Share this question
or