working operations on rows on event fire

  • I have a a grid on my asp.net page and grid has a delete link by which i delete a row from grid so as database with rowdelete event of grid using one id as uniquecolumn and rows on the basis of this column. now this unique colum is like uq00001/1 and its varchar. i want that when i delete one row from grid for example grid has 5 rows and i am deleting 3rd row so in database the unique id ll be like uq0001/1,uq0002/2,uq0003/3.. nowif i delete third row from grid then the row ll ve deleted from database and the other ids after these ll be adgested. eg. when thrid row is deleted then the 4rth row ll become uq0003 and 5th ll become uq004.. like wise i have to do to increment also when add row in grid. but deletion is where i am stucked in .

    and i want to do this through database. i have tried cursor inside a stored procedure but its not working.

    And no sugestions please because i have to achive this task to use this in some other purpose also .so dont reply as this is not needed or better do something else. I need a technical solution to the abouve problem and not whether i should go this way or not.

    Thank you

  • You better not update the IDs.

    Is any valid reason or requirement to do it?

    At the end you don't need the cursor to do re-numbering.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • yes i have to refresh the ids because if row 3 is deleted then row 4 ll have number 4 and 5 ll have 5 but after deleting 3rd row the 4rth row should become 3 and 5th should become 4

  • What the row number is to do with ID's of records?

    Just delete it and that's it, when retrieving records back order them by ID. You should not delete record by it's position, just by ID

    See example:

    Let say you added records as :

    uq001 val1

    uq002 val2

    uq003 val3

    uq004 val4

    When you want to display them, if you wish, you oder them by ID.

    When you want to delete the second record, you use ID of the record you want to delete (not its Row position number).

    When record with id of uq002 is deleted, you retrieve all records back again ordering by ID so records will be displayed as

    uq001 val1

    uq003 val3

    uq004 val4

    virtually making your 3rd record displayed as 2nd and 4th as 3rd.

    Linking row position number with the record ID does not look appropriate in your case.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply