473,395 Members | 1,456 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,395 software developers and data experts.

need help with error message

TJS
When trying to delete a row from a datagrid I get this error on every record
regardless of record selected to delete.
"Index 7 is not non-negative and below total rows count."

there are 8 rows in the table being edited so index 7 should be a valid
number

========= the offending code =================

Private _dataGridData As New DataTable()
Private _dataGridView As New DataView()
......

Private Sub DeleteRow(rowIndex As Integer)

_dataGridView = _dataGridData.DefaultView

If _dataGridData.Rows.Count >= rowIndex Then
' Delete row from datatable
Dim row As DataRow = _dataGridView(rowIndex).Row
row.Delete() '<=== won't go past this point
End If

End sub
Nov 19 '05 #1
4 1137
pj
On Wed, 2 Mar 2005 16:21:32 -0800, "TJS" <no****@here.com> wrote:
When trying to delete a row from a datagrid I get this error on every record
regardless of record selected to delete.
"Index 7 is not non-negative and below total rows count."

there are 8 rows in the table being edited so index 7 should be a valid
number
Are there 8 rows in the DataView as well? Perhaps you have a filter in
place and _dataGridData.DefaultView has fewer rows than
_dataGridData.

pj


========= the offending code =================

Private _dataGridData As New DataTable()
Private _dataGridView As New DataView()
......

Private Sub DeleteRow(rowIndex As Integer)

_dataGridView = _dataGridData.DefaultView

If _dataGridData.Rows.Count >= rowIndex Then
' Delete row from datatable
Dim row As DataRow = _dataGridView(rowIndex).Row
row.Delete() '<=== won't go past this point
End If

End sub


--
http://www.psychedelicjones.com/
Nov 19 '05 #2
TJS
I don't know how to confirm that ..

"pj" <pj@psychedelicjones.com> wrote in message
news:lc********************************@4ax.com...
On Wed, 2 Mar 2005 16:21:32 -0800, "TJS" <no****@here.com> wrote:
When trying to delete a row from a datagrid I get this error on every
record
regardless of record selected to delete.
"Index 7 is not non-negative and below total rows count."

there are 8 rows in the table being edited so index 7 should be a valid
number


Are there 8 rows in the DataView as well? Perhaps you have a filter in
place and _dataGridData.DefaultView has fewer rows than
_dataGridData.

pj


========= the offending code =================

Private _dataGridData As New DataTable()
Private _dataGridView As New DataView()
......

Private Sub DeleteRow(rowIndex As Integer)

_dataGridView = _dataGridData.DefaultView

If _dataGridData.Rows.Count >= rowIndex Then
' Delete row from datatable
Dim row As DataRow = _dataGridView(rowIndex).Row
row.Delete() '<=== won't go past this point
End If

End sub


--
http://www.psychedelicjones.com/

Nov 19 '05 #3
pj
On Wed, 2 Mar 2005 19:01:46 -0800, "TJS" <no****@here.com> wrote:
I don't know how to confirm that ..
if _dataGridView.Items.Count >= rowIndex etc... ?

pj

"pj" <pj@psychedelicjones.com> wrote in message
news:lc********************************@4ax.com.. .
On Wed, 2 Mar 2005 16:21:32 -0800, "TJS" <no****@here.com> wrote:
When trying to delete a row from a datagrid I get this error on every
record
regardless of record selected to delete.
"Index 7 is not non-negative and below total rows count."

there are 8 rows in the table being edited so index 7 should be a valid
number


Are there 8 rows in the DataView as well? Perhaps you have a filter in
place and _dataGridData.DefaultView has fewer rows than
_dataGridData.

pj


========= the offending code =================

Private _dataGridData As New DataTable()
Private _dataGridView As New DataView()
......

Private Sub DeleteRow(rowIndex As Integer)

_dataGridView = _dataGridData.DefaultView

If _dataGridData.Rows.Count >= rowIndex Then
' Delete row from datatable
Dim row As DataRow = _dataGridView(rowIndex).Row
row.Delete() '<=== won't go past this point
End If

End sub


--
http://www.psychedelicjones.com/


--
http://www.psychedelicjones.com/
Nov 19 '05 #4
TJS
thanks for replying ..

I found the problem , it was looking for a primary key field, which was
missing from the query.
the error message was not very helpful in this case.

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
15
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
2
by: CSDunn | last post by:
Hello, I need some assistance with error handling in an Access 2003 Project form. The project is has a data source connection to a SQL Server 2000 database. The main form is named...
1
by: Marco Krechting | last post by:
Hi All, This is a response on my earlier posting about trapping the standard access error message when you click on a hyperlink field and the file cannot be found. I know now how to work on the...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
2
by: Charles | last post by:
I need to find a way to share information between two classes, one is an employee class and the other is a custom error class that inherits from ApplicationException. These two classes are part of...
12
by: Noel | last post by:
Hello, I'm currently developing a web service that retrieves data from an employee table. I would like to send and retrieve a custom employee class to/from the webservice. I have currently coded...
12
by: Karina | last post by:
Hello: I am taking over someone else's code and my users are experiencing tons of problems but when I try to go into the source code to edit and try to fix these problems, I realize that all the...
5
by: Chuck Anderson | last post by:
I run Apache 2.0.55, and Php (both 4.4.1 and 5.2.5) on my home PC (Windows XP). One of the scripts that I run daily needs to access a secure URL (https://..............). When I am running Php4,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.