I need to format few strings when in edit mode. In line I have done it with the designer.
This is the code I am using for the formatting in edit mode:
The problems I have are the following:
1) When I click add a new row I get an exception because the text boxes are still empty, so the above methods try to format a null value. I do I get around this problem ?
2) The above code formats the numeric string, how do I format the other fields containing date time? I need {0:MMM/yyyy}
Thanks for supporting,
Felice
This is the code I am using for the formatting in edit mode:
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["Due"].Controls[0]; string dataFormatString = (RadGrid1.MasterTableView.GetColumn("Due") as GridBoundColumn).DataFormatString; txt.Text = String.Format(dataFormatString, double.Parse(txt.Text)); } if (e.Item is GridEditableItem && e.Item.IsInEditMode) { GridEditableItem edit = (GridEditableItem)e.Item; TextBox txt = (TextBox)edit["Paid"].Controls[0]; string dataFormatString = (RadGrid1.MasterTableView.GetColumn("Paid") as GridBoundColumn).DataFormatString; txt.Text = String.Format(dataFormatString, double.Parse(txt.Text)); } if (e.Item is GridEditableItem && e.Item.IsInEditMode) { GridEditableItem edit = (GridEditableItem)e.Item; TextBox txt = (TextBox)edit["Expenses"].Controls[0]; string dataFormatString = (RadGrid1.MasterTableView.GetColumn("Expenses") as GridBoundColumn).DataFormatString; txt.Text = String.Format(dataFormatString, double.Parse(txt.Text)); } }1) When I click add a new row I get an exception because the text boxes are still empty, so the above methods try to format a null value. I do I get around this problem ?
2) The above code formats the numeric string, how do I format the other fields containing date time? I need {0:MMM/yyyy}
Thanks for supporting,
Felice