AutoIncrement of KeyField giving problem when record already exists

12 replies. Last post: June 21, 2010 5:53 AM by Glenn Layaar
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback

Hi,

I want to use the Batch Update functionality for Web Grid. For this i set the DataKeyField of RootTable.Columns and add a column with DataMember of DataKeyField, and set its AutoIncrement property to true.

I allow user to Add,Update or Delete any record in the grid. Everything works great when there is no data in the grid.


But suppose if there are any existing records in the grid, It gives a problem.

The AutoIncrement column always starts its counter from 0, irrespective of data that already exists in that field.

Suppose i have set DataKeyField to "Id" Column.. Here's the structure

Id             FirstName                  LastName

1                John                             Doe

2                Tim                              Brooklin


This record comes up in the grid once i open the page, now when i add a new record the new record is given the Id of 0, Now again i enter second new record its given an id of 1 by Auto Increment column.


If you see the Id 1 already existed in grid that was rendered in first page load and after that i enter 2 new records i get the same id of 1, which is a big problem..


Why is it happening so, why is the AutoIncrement not taking into picture the existing records and generate the new id based on the highest value of that column.

I dont want to update the database every time when a new record is entered, I want to update the database only when the user has finished updating the whole grid data.

How can i accomplish this?



Thanks,

Huzefa

All times are GMT -5. The time now is 8:01 PM.
Previous Next