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

Setting datatype of column with code behind

3 Answers 201 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Cameron Molyneux
Top achievements
Rank 1
Cameron Molyneux asked on 27 May 2010, 10:28 AM
I'm trying to set the data type of one of my columns  with code behind using the following code but it is erroring

Can anyone explain what i'm doing wrong?

column.DataType = typeof(DateTime);



3 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 27 May 2010, 01:04 PM
Hello Cameron Molyneux,

 Could you share a bit more information about your scenario? What is the incoming data's type, what is the error you're getting, etc.

Sincerely yours,
Yavor Georgiev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Cameron Molyneux
Top achievements
Rank 1
answered on 27 May 2010, 01:23 PM
Unfortunately its a bit rubbish!!

we call a service and get a dataset returned .. all the columns are typed as string

i was hoping that the string would automatically cast as a date if we typed the column as a date

the date format is 27/05/2010 for example

the issue i'm having is when we try and sort by the column .. as it is it doesnt sort as a date would
0
Vlad
Telerik team
answered on 27 May 2010, 01:28 PM
Hello,

Casting one type to other will not convert anything. You need to create DateTime from this string to achieve your goal.

Kind regards,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Cameron Molyneux
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Cameron Molyneux
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or