Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > ItemDataBound doesn't fire when I use DeleteCommand

Reply
Thread Tools

ItemDataBound doesn't fire when I use DeleteCommand

 
 
Peter Afonin
Guest
Posts: n/a
 
      11-19-2003
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataList.DeleteCommand event is not getting fired Nathan Sokalski ASP .Net 4 05-21-2006 05:17 PM
ItemDataBound event does not fire for selected row. =?Utf-8?B?Z3JlZW5i?= ASP .Net 1 04-24-2006 04:04 PM
When I click the cancel button of the DataGrid control, it raises DeleteCommand event!!! Why???????? XueWu ASP .Net 0 07-12-2005 01:42 PM
ItemDataBound doesn't fire when I use DeleteCommand Peter Afonin ASP .Net 2 11-19-2003 05:26 PM
ItemDataBound doesn't fire when I use DeleteCommand Peter Afonin ASP .Net Web Controls 2 11-19-2003 05:26 PM



Advertisments