472,122 Members | 1,507 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,122 software developers and data experts.

"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 I get the following error

Deleted row information cannot be accessed through the row.

Heres my code for the editable datagrid
Private Sub dgEditEducation_ItemCommand(ByVal source As Object, ByVal e As

System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
Select Case e.CommandName
Case "Update"
tblEducation = Cache.Get("tblEducation")
Dim dr As DataRow
'find the row which has been clicked on
dr = tblEducation.Rows.Item(e.Item.ItemIndex) '.Find(CType
(E.Item.FindControl("lblEduID2"), Label).Text)
dr("institute") = CType(e.Item.FindControl("txtEdEInstitute"), TextBox).Text
dr("location") = CType(e.Item.FindControl("txtEdELocation"), TextBox).Text
dr("eYear") = CType(e.Item.FindControl("ddEdEYar"), DropDownList)
dr("major") = CType(e.Item.FindControl("txtEdEMajor"), TextBox).Text
dr("eType") = "q"
Cache.Insert("tblEducation", tblEducation)
dgEditEducation.EditItemIndex = -1
Case "Edit"
dgEditEducation.EditItemIndex = e.Item.ItemIndex
Dim dr As DataRow
tblEducation = Cache.Get("tblEducation")
dr = tblEducation.Rows(e.Item.ItemIndex)
Dim ddl As DropDownList =

CType(dgEditEducation.Items(dgEditEducation.EditIt emIndex).FindControl
("ddEdEYar"), DropDownList)
ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByValue((dr("eYear "))))
Case "Cancel"
dgEditEducation.EditItemIndex = -1
Case "Delete"
tblEducation = Cache.Get("tblEducation")
Dim dr As DataRow = tblEducation.Rows(e.Item.ItemIndex)
Cache.Insert("tblEducation", tblEducation)
dgEducation.ShowFooter = False
dgEducation.EditItemIndex = -1
End Select
End Sub

I really need to know what the problem is as its driving me nuts

Message posted via http://www.dotnetmonster.com
Nov 19 '05 #1
0 7198

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

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.