I am populating the grid with the data in page load. I have a imagebutton in a templateColumn in the grid which I am using to delete rows from the grid.Now I am handling the deletion of a row from the grid in CellSelectionChanged event of the grid. I am deleting the selected row from the datatable that I am using to bind the grid and providing the changed datatable as datasource for the grid.
I am getting the following error when I click on the imageButton in the TemplateColumn of the grid.
" This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row."
Is there any way to fix the mentioned issue?
I am providing the code that I have used to populate the grid and achieve the delete functionality.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me
.Load
Then
Session(
)
UtilityConstant.SubmissionsDtSession) =
Nothing
If
PopulateGridForSubmissions()
Sub
Private Sub PopulateGridForSubmissions()
Try
.GetSubmissionId()
gvSubmissions.DataSource = Session(
.SubmissionsDtSession)
Else
SubmissionDetailsList = GetSubmission(submissionIdValue)
dtSubmissions = GetSubmissionsDataTable(SubmissionDetailsList)
.SubmissionsDtSession) = dtSubmissions
gvSubmissions.DataSource = dtSubmissions
gvSubmissions.DataBind()
gvSubmissions.Columns(0).Hidden =
True
gvSubmissions.Columns(3).Hidden =
Catch
ex As Exception
gvSubmissions.CellSelectionChanged
lblError.Text =
.Empty
subPkgId = gvSubmissions.Rows(e.CurrentSelectedCells(0).Row.Index).Items(3).Text
dtSubmissionsDelete.Rows
.ToUInt64(subPkgId))
rowDelete.Delete()
dtSubmissionsDelete.AcceptChanges()
.SubmissionsDtSession) = dtSubmissionsDelete
Exit For
Next
In the above code, I have used constants for all Session names and names of the columns.
Hi Romita,
It is very hard to guess exactly where this exception is coming from. If you attach a small sample to show this, someone should be able to help.
regards,
David Young