c# - Error: Deleted row information cannot be accessed through the row -
to whom may concern, have searched considerable amount of time, work way out of error
"deleted row information cannot accessed through row"
i understand once row has been deleted datatable cannot accessed in typical fashion , why getting error. big issue not sure desired result, outline below.
basically when row in "dg1" deleted row beneath takes place of deleted row (obviously) , inherits deleted rows index. purpose of method replace , reset rows index (via grabbing corresponding value in dataset) took deleted rows place , such index value.
right using label (lbltext) try , response process, crashes when last nested if statement trys compare values.
here code:
void dg1_click(object sender, eventargs e) { rowindex = dg1.currentrow.index; //gets current rows string value = convert.tostring(dg1.rows[rowindex].cells[0].value); if (ds.tables[0].rows[rowindex].rowstate.tostring() == "deleted") { (int = 0; < dg1.rows.count; i++) { if (convert.tostring(ds.tables[0].rows[i][0].tostring()) == value) // ^ **where error occurring** { lbltest.text = "aha!"; //when working, place index of compared dataset value rowstate, displaying current index of row focussed on in 'dg1' } } }
thanks ahead of time help, did search, , if easy figure out through simple google search allow myself repeatably hate on me, because did try.
- gc
the current value data column in inner if statement not available deleted rows. retrieve value deleted rows, specify want original value. should fix error:
if (convert.tostring(ds.tables[0].rows[i][0, datarowversion.original].tostring()) == value)
Comments
Post a Comment