I urgently need a help ..and hight appriciate if experts on this forum can respond with a code snippet
I am editing a datagrid Cell with below code ( on cellEditEvent) , Function works perfectly fine when i changed the value for cell first time...but if tried to change any other cell value ( after successfully trying once) ... it goes to the same celleDit function and throw following exception
System.FormatException was unhandled by user code
Message="Input string was not in a correct format."
StackTrace:
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Int32.Parse(String s)
at HandlingUnit.SourcePackaging.RadGridViewValidation_EditEnded(Object sender, GridViewCellEditEndedEventArgs e)
InnerException:
*****************************************************************8
My code
private void RadGridViewValidation_EditEnded(object sender, GridViewCellEditEndedEventArgs e)
{
int OldCellValue = int.Parse(e.OldData.ToString());
int NewCellValue = int.Parse(e.Cell.Content.ToString());
if ((OldCellValue > 1) &&(e.Cell.ParentRow.Cells[3].Content.ToString()==""))
{
objTargetAllocHUdata.TargetHUItemNo = e.Cell.ParentRow.Cells[1].Content.ToString();
objTargetAllocHUdata.TargetHUQuantity = TargetHuQuantity.ToString();
objTargetAllocHUdata.TargetHUSerialNo = e.Cell.ParentRow.Cells[3].Content.ToString();
//objTargetAllocHUdata.TargetSerializableOrNot = row.Cells[4].Content.ToString();
objTargetAllocHUdata.TargetHandlingUnitNo = (HUAutoGeneratedNo + 1).ToString();
//Adding to Target list
lstTargetAllocHUData.Add(objTargetAllocHUdata);
this.TargetRadGridView.Rebind();
this.TargetRadGridView.ItemsSource = lstTargetAllocHUData;
}
public SourcePackaging()
{ InitializeComponent();
lstTargetAllocHUData= GetMessages().ToList();
this.SourceRadGridView.ItemsSource = GetMessages();
this.SourceRadGridView.CellEditEnded += this.RadGridViewValidation_EditEnded;
this.SourceRadGridView.ValidationMode = ValidationMode.Cell;
}