472,328 Members | 1,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Autoincrement Column contains null Values

108 100+
I have a DataTable with thousands of records, i want to show these records on per page basis ( i.e a DataGridView showing first 20 records and next button to show next 20 records ...)

To achieve this, i have added an Autoincrement Column to the DataTable so that i can use a filter on the Autoincrement Column to get the desired 20 records from the DataTable. I have used the following code
Expand|Select|Wrap|Line Numbers
  1. Dim dc As New DataColumn("Serial",System.Type.GetType("System.Int32"))
  2.         dc.AutoIncrement = True
  3.         dc.AutoIncrementSeed = 1
  4.         dc.AutoIncrementStep = 1
  5.         dt.Columns.Add(dc)
'dt' is the object of DataTable

When i set the datasource of DataGridView to this DataTable, i see null values in the Serial Column

Question is:
How can i get the Autoincrement Column working (with values)

I can't query the database, all i have to do is play around with the available DataTable
Dec 25 '08 #1
1 3643
569 Expert 512MB
AutoIncrement will only work for newly added rows to a datatable. Not for an extra column you add to a datatable. Why don't you use the rownumber of the datatable as Serial? After all, that is a unique AutoIncement number.

Dec 29 '08 #2

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

Similar topics

by: Marko Maehner | last post by:
Hi, I have a strange problem with my xml file. In the schema of this xml file I have set one column to autoincrement. When I enter the data in...
by: RA | last post by:
Hi I have the following datarow that I want to add to a datatable. DataRow newRow = ds.Tables.NewRow (); newRow = Cache.ToString (); newRow...
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application:...
by: Agnes | last post by:
I got master-detail relationship grid. in my detail grid, i set the column ..autoincrement. that grid contains serveral column.1st column is...
by: Dennis | last post by:
I have set a DataTable and one of the columns I set "AutoIncrement" to True. I then populate the Table by setting the columns to values then add...
by: Sam | last post by:
Hi all I have a simple datagrid form which has 4 columns. The first one is used just like a key and the other threes allow user to enter numbers....
by: JC Voon | last post by:
Hi: How to reset the autoincrement value generated by DataTable ? I've master and detail table, the detail table has a autoincrement column,...
by: Grzes_P | last post by:
J have database DB2 and create table T_TEST with fields: ID - integer autoincrement NAME - varchar(50) QTY - Integer I create java bean CMP and...
by: =?iso-8859-2?Q?Marcin_Dzi=F3bek?= | last post by:
Hi All: I need to get (filter in) some dataview's rows with DBNULLs in column of boolean type: Actually to get the only rows with DBNULL, I use...
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.