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

[Solved] How to clear the value of GridDateTimeColumn at runtime?

1 Answer 179 Views
Grid
This is a migrated thread and some comments may be shown as answers.
anonym
Top achievements
Rank 1
anonym asked on 12 May 2009, 08:54 AM
Hello, i have a GridDateTimeColumn which has some invalid dates like 01.01.1753

Now i want to replace that date with string.empty, where must i do it, can you give me an example please.





1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 May 2009, 10:30 AM
Hi Anonym,

I guess you do not want to show dates with year less than some limit. If so try with the following approach and see whether it helps.

CS:
 
 protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if(e.Item is GridDataItem) 
        { 
         GridDataItem item=(GridDataItem)e.Item; 
         if (item["EndDate"].Text!= " "
         { 
             DateTime EndDate = Convert.ToDateTime(item["EndDate"].Text); 
             if ((EndDate.Year < 1900)) 
             { 
                 item["EndDate"].Text = string.Empty; 
             } 
         } 
        } 
  } 

Thanks
Shinu



Tags
Grid
Asked by
anonym
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or