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

currency format in in editmode

1 Answer 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joslyn
Top achievements
Rank 1
Joslyn asked on 19 Dec 2013, 02:20 PM
hi 
i hav a gridboundcolumn with price as datafield. Dataformatstring is currency. This is all ok.but when in edit mode the currency symbol is not maintained.how to have the same format in edit mode?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 Dec 2013, 02:27 PM
Hi Joslyn,

Please try the following code snippet.

ASPX:
<telerik:GridBoundColumn DataField="UnitPrice" HeaderText="UnitPrice" UniqueName="UnitPrice"
  DataFormatString="{0:c}" />

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem edit = (GridEditableItem)e.Item;
        TextBox txt = (TextBox)edit["UnitPrice"].Controls[0];          
        string dataFormatString = (RadGrid1.MasterTableView.GetColumn("UnitPrice") as GridBoundColumn).DataFormatString;
        txt.Text = String.Format(dataFormatString, double.Parse(txt.Text));
    }
}

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