469,097 Members | 1,481 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,097 developers. It's quick & easy.

"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 7077

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.