Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
445
Formatted Date Value in UltraGrid
posted

I have an UltraGrid and one of the columns is for user to enter Date in the format of "yyyy-mm-dd" (eg. "2010-08-09"). So I set the column to do that as below:

 column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Date;

column.MaskInput = "yyyy-mm-dd";

column.Format =

 

"yyyy-mm-dd";

The display and editing works just fine. The problem is after user finished editing, I need to retreive the date in that format. So I used the following code:

 

 

string

 

 

dateValue = grid.Rows[0].Cells["MyDateCol"].Value.ToString();

The "dateValue" output is "8/9/2010 12:00:00 AM", which is not formatted and also includes the time. I only want the formatted date which should be "2010-08-09". So how to retrieve that formatted date?

Thanks!

 

 

 

 

 

 

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    The Value property on the column will return to you a DateTime variable. So if you want to format the date, you could pass the format into the ToString method to get a formatted string.

    Another option would be to use the Text property of the cell instead of Value.

Children