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

formatting radgriddateView

3 Answers 53 Views
GridView
This is a migrated thread and some comments may be shown as answers.
mampus
Top achievements
Rank 1
mampus asked on 21 Oct 2010, 06:21 PM
Hi there,
is there any way to set the default year when the radgriddateview is load.??
here my problem: i Have column call  "birthday"...i want to set the default year when loaded to 1980..
how i do that..???

3 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 21 Oct 2010, 07:30 PM
Hello Mampus,

You could just set the NullValue when you are creating the column, like so:
var dateTimeColumn = new GridViewDateTimeColumn("Date");
dateTimeColumn.NullValue = new DateTime(2000, 1, 1);
radGridView1.Columns.Add(dateTimeColumn);

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
0
Abba
Top achievements
Rank 1
answered on 28 Feb 2016, 05:46 PM

I know this is older post.  But related to this, is there a way to do it when binding data from a datatable to the grid?

Or is the way to loop thru the columns created and set NullValue

Or is the way to set in cellFormatting if DbNull make value "SOMETHING"

 

Thanks,

0
Dimitar
Telerik team
answered on 29 Feb 2016, 10:59 AM
Hi Abba,

Thank you for writing.

When the columns are autogenerated you only need to cast the column to the proper type in order to set the NullVallue:
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    foreach (var item in radGridView1.Columns)
    {
        if (item is GridViewDateTimeColumn)
        {
            GridViewDateTimeColumn col = item as GridViewDateTimeColumn;
            col.NullValue = new DateTime(2000, 1, 1);
        }
    }
}

I hope this helps.

Regards,
Dimitar
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
mampus
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Abba
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or