473,804 Members | 3,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Autoincrement Column contains null Values

rizwan6feb
108 New Member
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)
  6.  
'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 3774
MrMancunian
569 Recognized Expert Contributor
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.

Steven
Dec 29 '08 #2

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

Similar topics

0
1633
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 my xml file directly, the autoincrement-column gets its correct values. Now I want to add new data with the help of a dataset. I use the following lines of code:
2
1403
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 = Cache.ToString (); ds.Tables.Rows.Add (newRow);
1
4239
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: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get the example to work. I created the following two classes, provided with the example: *-*-**-*-*-*-*-*-*-*-*-*-**-*-*-*-*-CheckBoxColumn Class:-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-**-*-*-*
0
1175
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 description. 1)the user input 2rows. and then press' enter' in 3rd rows. as the user want to modify the 1st row. the user use upper arrow to move up. Now, after modification, the user press 'enter' to move foward 2nd rows. and 3rdrow. The problem is the 3rd row 's seqno should be 30. but it changed...
6
16135
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 the row to the table. I inadverently set the AutoIncrement Columns to different values but didn't get any errors. Should I be able to set the value of an AutoIncrement Column? I would have thought it couldn't be done as the column value was set when a row was added. -- Dennis in Houston
1
1638
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. The problem that I am having is that when I click on a cell of a new row but decide not to enter a value and go back to any of the previous rows for editting or whatever reason, the value of the new row will be incremented by value of the AutoIncrementStep Here is the problem I have
5
8103
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, each time i add a new master record, i need to reset the detail table autoincrement column to start from 1. I set the dataColumn AutoIncrementSeed=0 and AutoIncrementStep=1 each time i append a new master row, but it seem not work, it still remain
1
7928
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 install it on Jboss server and when create new record from client I get error: com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -798, SQLSTATE: 428C9, SQLERRMC: ID
6
17515
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 code like this: DV.RowFilter = "(IsNull(MyBooleanColumnName, True) = True) AND (IsNull(MyBooleanColumnName, False) = False)" or ex. DV.RowFilter = "(IsNull(MyIntegerColumnName, 1) = 1) AND (IsNull(MyIntegerColumnName, 0) = 0)" for columns of Integer...
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9132
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.