ItemDataBound doesn't fire when I use DeleteCommand

Discussion in 'ASP .Net Datagrid Control' started by Peter Afonin, Nov 19, 2003.

  1. Peter Afonin

    Peter Afonin Guest

    Hello:

    I'm deleteing data using Datagrid, then rebind it. For some reason
    ItemDataBound event doesn't fire after DeleteCommand. Why is this? Is it by
    design, or I'm missing something? I have some important calculations in
    ItemDataBound event. My code for DeleteCommand is below.

    I would appreciate your help very much.

    Private Sub dgData_DeleteCommand(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    dgData.DeleteCommand
    Dim lbl As Label
    Dim nID As String
    Dim dv As DataView
    Try
    lbl = CType(e.Item.FindControl("lblID"), Label)
    nID = CInt(lbl.Text)
    oCnn.ConnectionString = smi_class.Constants.Wip7bConnectionString
    oCnn.Open()
    With oCmd
    ..Connection = oCnn
    ..CommandType = CommandType.StoredProcedure
    ..CommandText = "dbo.uspDeletePressOrder"
    End With
    With oCmd.Parameters
    ..Add("@ID", SqlDbType.Int).Direction = ParameterDirection.Input
    ..Item("@ID").Value = nID
    End With
    oCmd.ExecuteNonQuery()

    If Not IsNothing(Session("DV")) Then
    dv = CType(Session("DV"), DataView)
    dv.RowFilter = "ID = " & nID
    If dv.Count > 0 Then
    dv(0).Delete()
    End If
    dv.RowFilter = String.Empty
    Session("DV") = dv
    If dv.Count > 0 Then
    Me.dgData.DataSource = dv
    Me.dgData.DataBind()
    Else
    Me.dgData.Visible = False
    End If
    Else
    BindGrid()
    End If
    dgData.EditItemIndex = -1
    CalculateTotals()
    Catch ex As Exception
    Me.lblError.Text = "Error No.: " & Err.Number.ToString & " - " & ex.ToString
    Finally
    If Not IsNothing(oCmd) Then
    oCmd.Dispose()
    End If
    If Not IsNothing(cnn) Then
    If cnn.State = ConnectionState.Open Then
    cnn.Close()
    End If
    End If
    End Try
    End Sub

    Thank you,

    --
    Peter Afonin
     
    Peter Afonin, Nov 19, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Afonin
    Replies:
    2
    Views:
    457
    Peter Afonin
    Nov 19, 2003
  2. XueWu
    Replies:
    0
    Views:
    628
    XueWu
    Jul 12, 2005
  3. =?Utf-8?B?Z3JlZW5i?=

    ItemDataBound event does not fire for selected row.

    =?Utf-8?B?Z3JlZW5i?=, Apr 24, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    2,417
    =?Utf-8?B?Z3JlZW5i?=
    Apr 24, 2006
  4. Nathan Sokalski
    Replies:
    4
    Views:
    3,530
    Nathan Sokalski
    May 21, 2006
  5. Peter Afonin

    ItemDataBound doesn't fire when I use DeleteCommand

    Peter Afonin, Nov 19, 2003, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    173
    Peter Afonin
    Nov 19, 2003
Loading...

Share This Page