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

[Solved] getting GridDateTimeColumn DateTime value

4 Answers 353 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kip
Top achievements
Rank 1
Kip asked on 22 Jan 2010, 07:19 PM
When searching, I was able to find this http://www.telerik.com/community/forums/aspnet-ajax/grid/time-calculation-in-rad-grid.aspx

This is the solution I had initially implemented on my own, however i've since changed the format string and it can no longer be readily parsed by using DateTime.Parse().

Rather than doing some obscure string manipulation I'm wondering how I can access the raw data used when filling a specific cell. To clarify, I want to be able to access the data source used to build the cell, having only the GridDataItem to start.

4 Answers, 1 is accepted

Sort by
0
Kip
Top achievements
Rank 1
answered on 22 Jan 2010, 07:34 PM

looks like you can do something like this:
 

DateTime start = (DateTime)(RadGrid1.DataSource as DataTable).Rows[gdItem.RowIndex]["start"]; 

 


where gdItem is GridDataItem and "start" is the unique id of the column in the gird.

unfortunately it looks like DataSource is null if you bind the grid to a locally scoped dataset.

 

 

 

 

0
Martin
Telerik team
answered on 27 Jan 2010, 03:24 PM
Hello Kip,

I would suggest you to review the following help article:

Accessing cells and rows

I hope this helps,
Martin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kip
Top achievements
Rank 1
answered on 27 Jan 2010, 05:48 PM
I read over that prior to creating this topic, there is nothing in there about accessing the dataset used to create the cell... maybe im missing something? I dont want the string representation of the data.... I want to access the dataset used to fill a specific cell in the grid.

If you look at my second post in this thread I demonstrated one way to reference the dataset directly... unfortunately if you build/bind the dataset inside the NeedDataSource handler the DataSource field is null on postback.

 

0
Martin
Telerik team
answered on 28 Jan 2010, 02:01 PM
Hello Kip,

If you create the dataset inside the NeedDataSource event handler then this dataset will be available after this event has been fired. However RadGrid does not bind to its data source on every post back and therefore it does not fire the NeedDataSource event . Instead It saves its state in the viewstate and recreates itself from it.
For more information about RadGrid event sequence I would suggest you to review the following help article:

Event sequence

I hope this helps,
Martin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Kip
Top achievements
Rank 1
Answers by
Kip
Top achievements
Rank 1
Martin
Telerik team
Share this question
or