Click here to Skip to main content
15,902,198 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
hi, i am binding data into datable. now i have to add to column as Rowno to get row numbers.

i got solution using below coding:

C#
DataColumn Rowno= new DataColumn();
Rowno.DataType = System.Type.GetType("System.Int32");
Rowno.AutoIncrement = true;

column.AutoIncrementStep = 1;
chktb1.Columns.Add(Rowno);


chktb1 is datatable which filled records from database. please do not suggest to get row number from database. in my project requirement is need from front end. so , how to get autoincrement number from 1.

I am getting row number using autoincrement . but it starts from 0. i need, it should start from 1. Please help.
Posted
Updated 22-Nov-13 1:35am
v2

1 solution

Try this !

C#
DataColumn dcl = new DataColumn();
dcl.AutoIncrement = true;
dcl.AutoIncrementSeed = 1;
dcl.AutoIncrementStep = 1;
 
Share this answer
 
Comments
christhuxavier 22-Nov-13 7:28am    
Thanks a lot Dineshshp!.
King Fisher 22-Nov-13 7:46am    
accept your Solution if its right

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900