Hi all
I've just recently used aspx, and I've been given this application. I started to use paging, because the datagrid in the application is getting longer and longer.
Initially (before paging) the data is able to be deleted (the delete command acts as a link in datagrid), however since I've started using paging, I was unable to delete the data from the data grid.
My thought was that the delete command in not accessible at all... but I don't know where and which part is wrong.
Appreciate if anyone could help me out.
Code:
'Page Load
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Page.IsPostBack Then
Else
daOnbReport.Fill(DsOnbReport1)
dgOnbReport.DataBind()
End If
End Sub
'Delete command
Private Sub dgOnbReport_DeleteCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
connDVLPDAISY.Open()
daOnbReport.Fill(DsOnbReport1)
Dim key = dgOnbReport.DataKeys(e.Item.ItemIndex)
Dim dRow As DataRow
Dim delButton As LinkButton
Try
dRow = DsOnbReport1.ONB.FindByONB_ID(key)
dRow.Delete()
Catch ex As Exception
daOnbReport.Fill(DsOnbReport1)
Response.Write(ex)
End Try
daOnbReport.Update(DsOnbReport1)
daOnbReport.Fill(DsOnbReport1)
connDVLPDAISY.Close()
conditionSelected()
dgOnbReport.DataBind()
End Sub
'paging
Private Sub dgOnbReport_PageIndexChanged(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgOnbReport.PageIndexChanged
dgOnbReport.CurrentPageIndex = e.NewPageIndex
bindgrid()
End Sub
'binding grid after paging
Sub bindgrid()
Me.OracleSelectCommand1.CommandText = "SELECT STATEMENT"
daOnbReport.Fill(DsOnbReport1)
Try
dgOnbReport.DataBind()
Catch
dgOnbReport.CurrentPageIndex = 0
bindgrid()
End Try
dgOnbReport.DataBind()
End Sub