cutequencher Level: Trainee
 Registered: 12-07-2007 Posts: 1
|
error when commiting the row to the original data store(urgent)
i am having this error when i am about to delete a data row
inline with this is a message box saying:
object reference not set to an instance of an object. do you want to correct the value?
if i click yes, it will delete the row if no it will ignore the deletion
i've already checked all of my declarations and pretty sure that i've declared everything right.
here's my code:
Private Sub delCol_ButtonColumnClick(ByVal sender As Object, ByVal e As Leadit.ExtendedDataGrid.ButtonColumnEventArgs) Handles delCol.ButtonColumnClick
Dim row As Integer
Dim hourdiffBtn As Integer
Dim sBtn As DateTime
Dim eBtn As DateTime
Dim res As MsgBoxResult
row = Me.dtgCustomSched.CurrentRowIndex
res = MsgBox("Are you sure you want to delete the schedule on " + Me.dtgCustomSched.Item(row, 0), MsgBoxStyle.YesNo)
If res = MsgBoxResult.Yes Then
sBtn = Date.Parse(Me.dtgCustomSched.Item(row, 1))
eBtn = Date.Parse(Me.dtgCustomSched.Item(row, 2))
hourdiffBtn = getHrValue(sBtn, eBtn)
lastRowNumber = lastRowNumber - 1
Me.remainingHour2 = Me.remainingHour2 + hourdiffBtn
Me.txtLookUpHours.Text = remainingHour2.ToString
addSchedule.Table("ttcpcustomizedschedule").Rows.RemoveAt(row)
Else
Exit Sub
End If
End Sub
dtgcustomsched is the name of my datagrid
addsched is the name of the dataset
i made one of the datagrid cell as a customized button.. it already work fine with my other codes.. the problem only occur here
the error occurs on the line in bold.
also, this error only appears when i delete the last row on the datagrid, but if i delete anything rather than the last row everything works fine and no error is being detected
i am using vb.net 2002
please help. thanx!
|