473,549 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

deleting last row in a DataGrid

Hello NG,
i have this problem: in my application, i have a master-
detail form displaying two DataGrids binded to DataViews.
While the bindings work fine when moving through the
grids' rows or making insertions, i keep encountering a
problem when trying to delete the last row in a grid
(problem occurs with both grids). Deleting any row other
than the last will complete successfully.
I have tried to handle all the underlying DataViews' and
DataTables' events, but i couldn't solve my problem.
Neither could i solve the problem by catching exceptions:
all the form routines include structured exception
handling, but the run-time error i get is about a null-
reference unhandled exception. Is it depending on the
DataGrid control trying to move to the next row (which of
course does not exist)?
I would appreciate any help, thank you in advance.
Best regards,

J.
Nov 20 '05 #1
1 1762
Just a thought . . .

Are you using context menus to call a delete function, if so, is this being
caught on MouseDown rather than mouse up ?, had something simelar before and
changed it to mouseUp which cured it.

If this is not the error, you can zip up the project if its not too big and
post it here otherwise, email it to me and I will try and help

--
Regards - One Handed Man

Author : Fish .NET & Keep .NET
=============== =============== ===========
This posting is provided "AS IS" with no warranties,
and confers no rights.
"J. A. Zanetti" <ja****@spammer ssuck.org> wrote in message
news:11******** *************** *****@phx.gbl.. .
Hello NG,
i have this problem: in my application, i have a master-
detail form displaying two DataGrids binded to DataViews.
While the bindings work fine when moving through the
grids' rows or making insertions, i keep encountering a
problem when trying to delete the last row in a grid
(problem occurs with both grids). Deleting any row other
than the last will complete successfully.
I have tried to handle all the underlying DataViews' and
DataTables' events, but i couldn't solve my problem.
Neither could i solve the problem by catching exceptions:
all the form routines include structured exception
handling, but the run-time error i get is about a null-
reference unhandled exception. Is it depending on the
DataGrid control trying to move to the next row (which of
course does not exist)?
I would appreciate any help, thank you in advance.
Best regards,

J.

Nov 20 '05 #2

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

Similar topics

1
4161
by: Junkguy | last post by:
I'm having difficulty deleting rows from a datagrid. I want to put a "delete" button on a form and achieve the same functionality as hitting the "delete" key on the keyboard for the selected row of a datagrid. I really want to do it generically so I have subclassed datagrid and made my own delete row method but I can only get it to work for...
5
14721
by: Mojtaba Faridzad | last post by:
Hi, with SetDataBinding( ) a DataGrid shows a DataView. user can select some rows in the grid by holding cotrol key. when user clicks on Delete button, I should delete all selected rows. I am trying to delete these lines from the dataview like this: for (int i=0; i < dataView.Count; i++) if (dataGrid.IsSelected(i)) dataView.Delete(i);
2
8218
by: Alex K. | last post by:
I am using datagrid bound to a datatable: DataTable dt = ...; MyGrid.DataSource = new DataView(dt); Now I am trying to intercept delete operation, when user highlights a row and presses delete key. For this, I am using dt.RowDeleting event: private void dt_RowDeleting(object sender, DataRowChangeEventArgs e) {
0
1395
by: Hrvoje Vrbanc | last post by:
Hello, this is a problem I came upon while building a site based on MCMS 2002 but it's not strictly MCMS-oriented: I have a page that displays a certain content in presentation mode but when an editor clicks "Switch To Edit Site" in MCMS console on the page, the page displays a different content, an interface that editor use for upload and...
1
3067
by: | last post by:
Hello, I have a datagrid bound to a datatable which has an Identity column. I load the table from data in a spreadsheet and manually assign seq. values to the identity column. Once that is done, I set the AutoIncrement property to true and the AutoIncrementStep property to 1. When I try to delete the last row in the displayed grid, I get...
2
1122
by: rodchar | last post by:
hey all, i've got an asp.net page with a datagrid on it. when i delete all the rows in the datagrid it just shows the column headers. how are some ways i can clean that up? thanks, rodchar
10
2328
by: Nick | last post by:
Hello, Please pardon my ignorance as I'm sure this is easy to do. I have a datagrid where I want to let the user delete columns. I added a context menu to the datagrid that has a delete option. If the user right clicks on a column heading can I highlight that column and then delete it? I'm not exactly sure how to highlight it or figure out...
2
1148
by: Ryan Liu | last post by:
private void dt_RowDeleted(object sender, DataRowChangeEventArgs e) { int id= (int)e.Row; if(id >5) { e.Row.RejectChanges(); MessageBox.Show(this, "Can not delete!" + id); }
9
1708
by: Hamed | last post by:
Hello I have a DataGrid that a is bound to a DataTable. Some of the rows in the DataTable should not be deleted. How can I prohibit deleting of some identified rows? The problem could be specified in the following format too: There is a DataView object that I want to prohibit deleting of some of its DataRowView objects. that is: when...
0
7532
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...
0
7461
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7971
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...
0
7823
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...
1
5381
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...
0
5101
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3509
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...
1
1956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1068
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.