lundi 2 mars 2015

how do i Eliminate multiple Entries in GridView Telerik

I am Working on Windows Form Telerik. As I have Grid View of Telerik Control and i want to add New Entry into that. I have Button for create new Entry Click on that button Winform will popup and on that popup if i click on save it will add that row. But My Problem is that 1 Row added with that another Row also add which is not required.


My Code Is Below. public void Save(TimesheetEntry timesheetEntry) { if (timesheetEntry.TimesheetEntriesId == -1) { timesheetEntry.SequenceNumber = GetNextSequenceNumber(timesheetEntry.FileId, timesheetEntry.EntryDate); Add(timesheetEntry);



}
else
{
Update(timesheetEntry);
}
//Audit trail
//TODO:
//MyAuditTrialModel.Add<TimesheetEntry>(Helper.Actions.CU_Timesheet, Helper.TableNames.TimesheetEntry, timesheetEntry);
}</pre>


This one is Add Method:



<pre lang="cs">private TimesheetEntry Add(TimesheetEntry item)
{
_context.TimesheetEntries.AddObject(item);
_context.SaveChanges();
return item;
}</pre>


And On Edit Button also it will Generate 2 rows. which code is as below.



<pre lang="cs">private TimesheetEntry Update(TimesheetEntry item)
{
_context.TimesheetEntries.ApplyChanges(item);
_context.ObjectStateManager.ChangeObjectState(item, System.Data.EntityState.Modified);
_context.SaveChanges(true);
return item;
}</pre>

Aucun commentaire:

Enregistrer un commentaire