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

Format is not maintained in editmode

1 Answer 16 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alyssa
Top achievements
Rank 1
Alyssa asked on 30 Jan 2014, 12:58 PM
Hi ,
i have a grid in edit mode with bound columns. One of the column is of date type. To this i have set format string as MMM/yyyy , dat works fine, but in edit mode this format is not maintained. How to have same format in edit mode?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Jan 2014, 01:07 PM
Hi Alyssa,

Please try the following code snippet to set the format during edit mode:

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
 if (e.Item is GridEditableItem && e.Item.IsInEditMode)
 {
   GridEditableItem edit = (GridEditableItem)e.Item;
   TextBox textBox = (TextBox)edit["ColumnUniqueName"].Controls[0];
   textBox.Text = Convert.ToDateTime(textBox.Text).ToString("MMM/yyyy");
 }
}

Thanks,
Shinu
Tags
Grid
Asked by
Alyssa
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or