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

[Solved] Cell Edit event throwing exception

3 Answers 109 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nikhil
Top achievements
Rank 1
Nikhil asked on 01 Jun 2009, 04:57 AM
Hi,
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;

 

 

 

}

3 Answers, 1 is accepted

Sort by
0
Nikhil
Top achievements
Rank 1
answered on 01 Jun 2009, 05:12 AM
Further researching in to this suggest that 

When first time function is called below code executes successfully ,....but if a second cell is edited  e.OldData and e.NewData returns null or blank values ..and hence it is failing ,,,please suggest what should i do so that they don't take null/ blank values in second call of the function

private

 

void RadGridViewValidation_EditEnded(object sender, GridViewCellEditEndedEventArgs e)

 

 

{

 

int OldCellValue = int.Parse(e.OldData.ToString());

 

 

 int OldCellValue = int.Parse(e.OldData.ToString());

}
0
Nikhil
Top achievements
Rank 1
answered on 01 Jun 2009, 02:27 PM
Please provide some suggestion ,,this is really urgent...thansk a lot
0
Pavel Pavlov
Telerik team
answered on 04 Jun 2009, 12:54 PM
Hello Nikhil,

I am trying to reporduce the problem here.  Can you please send me  your project ? This will help me a lot to assist you. (you will need to open a support ticket in order to be able to add atachment) .

All the best,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Nikhil
Top achievements
Rank 1
Answers by
Nikhil
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or