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

RadGrid EditMode Generating invalid data

1 Answer 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Srujan
Top achievements
Rank 1
Srujan asked on 31 Oct 2013, 07:48 PM
Hi All ,

I am using grid control and enabled EditMode="EditForms" , when I try to edit a row numbers are displayed incorrectly as below 

Number on grid Display : ($267,641.00)
Number in Edit box : -,267,641.00

Comma between "-" and "2" , can anybody suggest to overcome this issue .

Thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Nov 2013, 07:34 AM
Hi Srujan,

Please try the following code snippet to maintain the DataFormat in editmode.

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
Srujan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or