following code will add a datacolumn which automatically increments the value of the column for new rows added to the table


DataColumn newcolumn=new DataColumn("studentID", System.Type.GetType("System.Int32"));
newcolumn.AutoIncrement = true;
newcolumn.AutoIncrementSeed = 1;
newcolumn.AutoIncrementStep = 1;

//// Add column to datatable.
DataTable mytable=new DataTable();
mytable.Columns.Add(column);

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/aGvq9wdqBdw/14593