473,320 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

[C#] problem with auto number in datatable

Dear All,

I having a datatable with the auto number, I need to know that how to restart/recalculate the auto number when a particular row being removed for example :
I have 5 row of record 1,2,3,4,5
When the row 2 being removed. i wanted it to show 1,2,3,4 instead of 1,3,4,5

Thank for helping
Feb 27 '09 #1
8 3724
Dear All,

I having a datatable with the auto number, I need to know that how to restart/recalculate the auto number when a particular row being removed for example :
I have 5 row of record 1,2,3,4,5
When the row 2 being removed. i wanted it to show 1,2,3,4 instead of 1,3,4,5

Thank for helping
Feb 27 '09 #2
Plater
7,872 Expert 4TB
Hide the autonumber column and number them yourself?
You cannot manually enter values in the autonumber column of a table.
If you delete one, you're stuck with a gap.
Feb 27 '09 #3
@Plater
Thanks for yoru reply .but how do number myself since the data is generated dynamically.
Feb 27 '09 #4
Plater
7,872 Expert 4TB
Loop through the rows and assign the number to a spare column?
Feb 27 '09 #5
@Plater
I don't know how to do it with the suggestion stated by you.

actaully my datatable is use to store shopping cart item.So the autonumber column is create/updated when one item added in.However when the user removed item from the cart the autonumber column become weird as i stated ealier
Feb 28 '09 #6
kunal pawar
297 100+
In database thats not posible, Either you have to use number in place of auto number fieled and put next numbers by useing code or trucate all records and again save records newly
Mar 2 '09 #7
@kunal pawar
Thank for your reply . One thing I need to make it clear. what I try to do with auto number is on datatable is not on database.


I aleready solved the problem by trasnfer it to another temporary datatable
Mar 2 '09 #8
Plater
7,872 Expert 4TB
If you make a spare column in your in your set of data, you can loop through the rows and assign a counter index to each of, for display purposes only
Mar 2 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
8
by: Bruce Stockwell | last post by:
the setup: Webservice/WinClient application/SQL server. VS.Net (visual basic) winform wizard creates a simple form with load cancel cancelall and datagrid bound to a simple Dataset with one...
0
by: Dave Elliott | last post by:
After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is after the newly added row without getting bizarre results. I have added the...
4
by: Shahar | last post by:
Hi I need to get a field name 'ID'(that is an auto-number field) right after I add a new row to table, it's work like that: myCommand.ExecuteNonQuery(); myCommand.CommandText = "SELECT...
1
by: Prince | last post by:
Hi all, Can anyone tell me how to create auto generated values in a DataTable column? Looking forward for the reply.... Thanx in advance...
13
by: Lars Netzel | last post by:
hi! myDataSet that is fillled from an Access 2000 db and includes ONE table From that Table in myDataSet I create myDataView and use a Rowfilter to get a few rows that i work with (i need a...
4
by: Hrvoje Voda | last post by:
How to automaticly add a new int number into table? I use a column ItemInx wich is Int32.
6
by: McKirahan | last post by:
I an using ASP to read a database table and generate an HTML table which is save via FSO with a file extension of .xls which opens up in MS-Excel. I am inserting several lines of text into a cell...
0
by: Ryan Liu | last post by:
I have a program works fine in .NET 1.1 and just recompiled in .NET 2.0 without any code change. Compiles OK, but there is an exeception when execute it. Then I remove PK, it works all fine...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.