Deleted row information cannot be accessed through the row.

I have a DataSet in which I need to make multiple changes prior to saving. Here's the scenario where I'm having the problem:
1. I delete a row and it disappears from the table.
2. I attempt to add another row.
3. I receive an error that "Deleted row information cannot be accessed through the row." when the the screen posts back and refreshes.

Here's the code for deleting:
<code>
protected void dgEmail_DeleteCommand(object
source, System.Web.UI.WebControls.DataGridCommandEventArgs e)

{

Debug.WriteLine("dgEmail_DeleteCommand");

EnableSaveBtn();

dgEmail.EditItemIndex = -1;

dsEmail.Tables["email"].Rows[e.Item.ItemIndex].Delete();

//dsEmail.Tables["email"].AcceptChanges();

dgEmail.DataSource = dsEmail;

dgEmail.DataMember = "email";

dgEmail.DataBind();

}</code>

If I uncomment the line to AcceptChanges the error no longer occurs but the row is not deleted from the database when I update everything.

0
cavedog6
10/3/2005 12:45:36 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

3 Replies
1225 Views

Similar Articles

[PageSpeed] 53

Try moving 'dgEmail.EditItemIndex = -1;' to where i have it bold and underline in your code and run it again.
Let us know if that fixed things.

Debug.WriteLine("dgEmail_DeleteCommand");

EnableSaveBtn();

dsEmail.Tables["email"].Rows[e.Item.ItemIndex].Delete();

//dsEmail.Tables["email"].AcceptChanges();

dgEmail.EditItemIndex = -1;

dgEmail.DataSource = dsEmail;

dgEmail.DataMember = "email";

dgEmail.DataBind();




Darmark

Mark as Answer, if this reply answers your post.
0
Darmark
10/3/2005 4:00:24 PM
No, that didn't fix it. Same error. The row deletes but if I try to add another one (or delete another one), I get the error. Optimally, I would like to make many changes to the DataSet and then save them all at one.
0
cavedog6
10/3/2005 5:39:19 PM
If the row is deleted from the DataSet and is reflected correctly in the grid after postback,
then the problem might be in your 'enableSaveBtn' code, as you said, the row is not being deleted in the database.

Also, what should you try doing instead is, have a checkbox column that's used to delete the rows you want. You can select all the rows you want to delete, add as many new rows you want, then click the button to have the code and database do the deleting and inserting, deleting the rows that have been checked and inserting the new ones.



Darmark

Mark as Answer, if this reply answers your post.
0
Darmark
10/3/2005 7:18:53 PM
Reply:

Similar Artilces:

"Deleted row information cannot be accessed through the row." WHY!!
hi guys, I have a problem with my datagrid. My form is set up so I have two textboxes an add button and an editable datagrid. The datagrid is bound to a datatable which is in my cache.When I click the add button the contents of the textboxes are insertedinto the datatabel in teh cache and the datagrid is bound to it. However the problem comes when I delete a row from the database and then add and edit a row. Lets say my datagrid has only one row, I delete it and then insert a new row. WHen I click on the Edit button of the new row that has been inserted I get the following error Delet...

adding / deleting table rows, and accessing controls within added rows
Hi everyone,I would like to know what is a good and simple way to achieve this using asp.net.  Basically i would like the ability to add and delete rows, preferably table rows.  Against each row is its delete button, hitting it will delete the corresponding row.  There is only 1 Add button to add a new row.  In each row, there are say 2 textboxes.  When i hit, say a calculate button, i wish to be able to access all the available textboxes in all the available rows in the event handler, and say just output a sum.If GridView is suggested, could you please explain why i...

accessing row by row
first of all sorry if i posted this in a wrong place but i'm new to powerbuilder and i have to develop a program quite quickly ( i only worked with acces until now) i have been provided a excel spreadsheet that contains all coloms and rows from all tables wich i have to insert in a database. The difficulty is that i can't use a datapipeline because i need to use a string function to check in wich table i have to put it: TABLENAME_COLUMNNAME -> i thought about using the string function to find out the right column in the right database. however i don't know how you ...

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

How to delete row from GridView control
Hello,  I am working on an ASP.NET 2.0 app, and I am trying to wire up a "Delete" button to a gridview control on a form. Here is the code for the ASP :  <asp:GridView ID="gvInConditions" runat="server" AutoGenerateColumns="true" OnRowDeleting="gvInConditions_RowDeleting" DataKeyNames="Condition_ID" >         <Columns>                <asp:CommandField ButtonType="Button" SelectText=&...

Delete Row Method (getting the primarykey of row being deleted)
Hello friends,I'd like to retrieve the primary key of the row being deleted so i can use it as a parameter in my stored procedure: Here's how far i have come with my code. I need help with line 6.Thanks in advance :)  1 Protected Sub DependentsObjectDataSource_Deleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles DependentsObjectDataSource.Deleting2 3 'get value of deleting depednent id4 'Delete (Unenroll) all benefits dependent enrolled in before attempting to delete dependen...

Delete row removes all rows
When datawindow row 1 is clicked and selected then a pfc_deleterow is issued all dw rows are deleted. dw_1 update spec is "update", not delete then insert. Only one key column on the table which is a serial column. ll_rtn = dw_1.event pfc_DeleteRow() ll_rtn count does indicate that all rows were deleted. If any other row is selected then only the selected row is deleted. When the window is 1st opened and row one is displayed but not selected, only row 1 is deleted. Is this the expected behavior? PB 7.02 8046, NT 4.0, and the corresponding version of SQLAnywhere (whate...

First Row, Next Row, Prior Row, Last Row
I have a SQL Anywhere 7.0 Database, have a table Product_detail which contains Column Name Datatype width Null Default batch_id char(10) No None prod_id Integer No None employee_id Integer No None quantity Integer No None price Numeric (14, 2) No None Its primary key is batch_id I have a Freeform Datawindow with this table I want to provide the first row, next row, prior row and last row Ho...

How to delete Datagrid row if that row is not selected
Hi, I faced a problem. I have a simple datagrid. It allows user to select a particular row of data say row 5. It works completely fine but if user wants to delete row 7 when row 5 is selected, the datagrid will delete 5 (which is the selected row) instead of 7. How to go about this issue? Thanks! Regards, FrancisSGDOTNET.ORG Can't you just select row 7 and delete it?Thanks!Bernie At first, DataGrid deletes nothing. It sends out only commands that your code has to handle. You have to use DeleteCommand event of datagrid. In this event you have to take the row index from event...

Delete a row and all other rows thats linked to it
Hii want to delete a row in my database but the problem is, i cant delete it as other table rows is linked to it.  I have to delete all the rows thats linked to the row i wanna delete first.Is there a easier way to delete the row and all the rows thats linked to it?  i wanna code it to do it.an suggestions? That's what cascading deletes are for, but that's in the database design.  Do searches on Declaritive Referential Integrity or DRI....

Deleteing rows in Row level Locking
When deleting rows on tables that use row level locking (ASE 11.92) the number of rows effected is not returned. Is there a way to obtained the number of rows marked as delete. This was needed to help verify an automated process of cleaning up our daily mess in one application. thank you, gfessen glen.fessenden@globalcrossing.com wrote... > When deleting rows on tables that use row level locking (ASE 11.92) the > number of rows effected is not returned. Is there a way to obtained the > number of rows marked as delete. This was needed to help verify an automated > p...

Accessing GridView Data Row By Row
guys i have just started with asp.net i have a basic doubt, i have created a SQL datasource and a gridview associated with it now what i need to do is get all the data from my database n modify it further, for this i need to access each row of the gridview any ideas on how to do so? foreach(GridViewRow row in GridViewName.Rows) { you can interate like this..  }Better Post your code before asking some thing, some one. So that person helping u will understand u r problem ClearlyYahoo IM : dotnetrulerI am trying to keep Frequently Asked Questions in my blog  When u enable show...

GridView.Rows.Count after deleting rows
How do I get the count of GridView's data rows that is displaying?If I use GridView.Rows.Count, after deleting a row, it won't change - as same as before deleting, and nor do GridView.DataKeys.Count.  My blog (zh-CN)Be and awear of who you are. Most likely, you'll have to re-bind the data after the deletion. If so, go ahead and retrieve your count during the DataBound event, then you'll know you're retrieving an accurate count.Thanks, EdMicrosoft MVP - ASP/ASP.NET Yes, that's the easiest way to do this.I finally chose another way: in DataBound event, record the count, and in&nb...

Web resources about - Deleted row information cannot be accessed through the row. - asp.net.presentation-controls

Information - Wikipedia, the free encyclopedia
Information (shortened as info or info. ) is that which informs, i.e. an answer to a question, as well as that from which knowledge and data ...

InformationWeek – Latest Information Technology (IT) news & IT articles - Technology news - IT magazine ...
InformationWeek provides latest Information technology (IT) news online & articles and publishes latest tech news & IT magazine for Indian IT ...

Laws to repress information about detention could be unconstitutional
George Williams tallies 350 Australian laws that now infringe basic democratic standards.

Personal information of more than 190m American voters appears online
Questions raised about the security chops of political campaigns who increasingly hold large caches of personal data. Information about 191 million ...

Researchers say retrieving information from a black hole might be possible
... script tells us we can enter a black hole and then use it to transcend space and time. In the film, the black hole also leaks out information ...

"Conservatives tend to be a lot more reactive to negative information and they also tend to be a lot ...
"... and they also tend to have less tolerance for ambiguity. Conservatives would prefer a negative concrete statement to a slightly positive, ...

New Media Completes Acquisition of the Business Information Division of Dolan LLC
New Media Investment Group Inc. (&ldquo;New Media&rdquo; or the &ldquo;Company&rdquo;, NYSE:NEWM) announced today that it has completed the previously ...

Samsung Galaxy S7 Release Date Rumor: China Mobile Leaks Information that S7 ...
Christian Post Samsung Galaxy S7 Release Date Rumor: China Mobile Leaks Information that S7 ... Christian Post Samsung Galaxy S6 Reuters/Kim ...

IDG Contributor Network: Information security don't let the apparent complexity intimidate you
... it was. This was a humbling experience, and cause for reflection. Those of us who spend most of our time immersed in the intricacies of information ...

A new thought experiment shows how we could get information from a black hole
Physicists think they've come up with a way to learn a bit about the interior of a black hole an impossible procedure that shows the insanity ...

Resources last updated: 1/7/2016 10:10:08 AM