Hi:
I have 2 columns that are OADate type (per RadChart). How do I format it in a data bound column? The column appear as a #, and when I try to set the FormatString as a date then it throws an exception.
Phil
p.s. Telerik opened pandora's box in RadChart.
I have 2 columns that are OADate type (per RadChart). How do I format it in a data bound column? The column appear as a #, and when I try to set the FormatString as a date then it throws an exception.
Phil
p.s. Telerik opened pandora's box in RadChart.
3 Answers, 1 is accepted
0
Hi Phil,
Is the issue you are facing with RadGrid or RadChart? What is the error message you see? Can you share the problematic columns declaration and elaborate on what you expect to see there?
Best wishes,
Iana Tsolova
the Telerik team
Is the issue you are facing with RadGrid or RadChart? What is the error message you see? Can you share the problematic columns declaration and elaborate on what you expect to see there?
Best wishes,
Iana Tsolova
the Telerik team
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 their blog feed now
0

Phil
Top achievements
Rank 2
answered on 12 Nov 2011, 01:15 AM
Hi
Sample
The dates are displayed as 29221 & 27945. I have a chart that I am also placing the supporting data is a grid.
Phil
Sample
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="Telerik" %>
<
script
runat
=
"server"
>
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime DOB { get; set; }
}
protected void Page_Load(object sender, System.EventArgs e)
{
if (!(IsPostBack)) {
var _list = new List<
Person
>()
{
new Person {FirstName = "One", LastName = "Person", DOB = DateTime.Parse("1980-01-01")},
new Person {FirstName = "Two", LastName = "Person", DOB = DateTime.Parse("1976-07-04")}
};
dateGrid.DataSource = (from _l in _list
select new { DOB = _l.DOB.ToOADate(), FirstName = _l.FirstName, LastName = _l.LastName });
dateGrid.DataBind();
}
}
</
script
>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"head"
Runat
=
"Server"
>
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"ContentPlaceHolder1"
Runat
=
"Server"
>
<
telerik:radgrid
ID
=
"dateGrid"
runat
=
"server"
AutoGenerateColumns
=
"False"
>
<
MasterTableView
DataKeyNames
=
"LastName"
>
<
Columns
>
<
Telerik:GridBoundColumn
DataField
=
"FirstName"
UniqueName
=
"FirstNameColumn"
HeaderText
=
"First Name"
/>
<
Telerik:GridBoundColumn
DataField
=
"LastName"
UniqueName
=
"LastNameColumn"
HeaderText
=
"Last Name"
/>
<
Telerik:GridBoundColumn
DataField
=
"DOB"
UniqueName
=
"DOBColumn"
HeaderText
=
"DOB"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:radgrid
>
</
asp:Content
>
Phil
0
Hello Phil,
I tested your code and I find the behavior you describe as expected. To further prove it I added a label to the page and set its text to the same value as in the grid column:
As a result the text displayed in the label was the same as this for the DOB column for the first row in the grid.
Can you elaborate on what is the desired effect and what you are trying to achieve?
Kind regards,
Iana Tsolova
the Telerik team
I tested your code and I find the behavior you describe as expected. To further prove it I added a label to the page and set its text to the same value as in the grid column:
<
asp:Label
ID
=
"Label1"
runat
=
"server"
/>
protected
void
Page_Load(
object
sender, System.EventArgs e)
{
if
(!(IsPostBack))
{
var _list =
new
List<Person>()
{
new
Person {FirstName =
"One"
, LastName =
"Person"
, DOB = DateTime.Parse(
"1980-01-01"
)},
new
Person {FirstName =
"Two"
, LastName =
"Person"
, DOB = DateTime.Parse(
"1976-07-04"
)}
};
dateGrid.DataSource = (from _l
in
_list
select
new
{ DOB = _l.DOB.ToOADate(), FirstName = _l.FirstName, LastName = _l.LastName });
dateGrid.DataBind();
Label1.Text = _list[0].DOB.ToOADate().ToString();
}
}
As a result the text displayed in the label was the same as this for the DOB column for the first row in the grid.
Can you elaborate on what is the desired effect and what you are trying to achieve?
Kind regards,
Iana Tsolova
the Telerik team
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 their blog feed now