473,508 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dataFrid Exception Error

I can't access the rows of my dataGrid after I call a dg.Delete() on some of
the rows.

I populate a datagrid from a datatable like this

dataGrid1.DataSource = dt;

Then I loop through each datarow deleting some of the rows like this:

dr.Delete();

I then refresh the grid to get the remaining rows in the grid like this:

dataGrid1.Refresh();

I then move the datagrid data into a datatable like this:

dt1 = (DataTable)dataGrid1.DataSource;

Then when I try to access the rows of data in the datatable like this:

sb.Append( dt1.Rows[ curRow][ curCol].ToString( ).Trim( ));

I get this exception:

"An unhandled exception of type
'System.Data.DeletedRowInaccessibleException' occurred in system.data.dll

Additional information: Deleted row information cannot be accessed through
the row."

What do I need to do to access the remaing rows in the datagrid.

Thanks

Paul

Nov 16 '05 #1
1 1894
Answer: You need to call datatable.AcceptChanges()

"Pa******@newsgroup.nospam" wrote:
I can't access the rows of my dataGrid after I call a dg.Delete() on some of
the rows.

I populate a datagrid from a datatable like this

dataGrid1.DataSource = dt;

Then I loop through each datarow deleting some of the rows like this:

dr.Delete();

I then refresh the grid to get the remaining rows in the grid like this:

dataGrid1.Refresh();

I then move the datagrid data into a datatable like this:

dt1 = (DataTable)dataGrid1.DataSource;

Then when I try to access the rows of data in the datatable like this:

sb.Append( dt1.Rows[ curRow][ curCol].ToString( ).Trim( ));

I get this exception:

"An unhandled exception of type
'System.Data.DeletedRowInaccessibleException' occurred in system.data.dll

Additional information: Deleted row information cannot be accessed through
the row."

What do I need to do to access the remaing rows in the datagrid.

Thanks

Paul

Nov 16 '05 #2

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

Similar topics

6
2322
by: Daniel Wilson | last post by:
I am having exception-handling and stability problems with .NET. I will have a block of managed code inside try...catch and will still get a generic ..NET exception box that will tell me which...
7
2690
by: Ekim | last post by:
hy, I've a question concerning exception-handling in c++: is there a possibility to catch any exception (I know one can do that by "catch(...)") and display its default-error-message (like in...
3
2931
by: Professor Frink | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
44
4162
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
40
13468
by: Kevin Yu | last post by:
is it a bad programming design to throw exception in the try block then catch it??
3
1835
by: will | last post by:
Hi all. I've got an question about how to catch an exception. In Page_Load, I place a DataGrid, dg1, into edit mode. This will call the method called GenericGridEvent. GenericGridEvent will call...
5
3396
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
9
2925
by: Jim | last post by:
Hello, I'm trying to write exception-handling code that is OK in the presence of unicode error messages. I seem to have gotten all mixed up and I'd appreciate any un-mixing that anyone can...
0
7227
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,...
0
7391
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...
0
7501
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...
0
5633
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,...
1
5056
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...
0
3204
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...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
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 ...
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.