|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
CancelCommand Event Handler Not FiringDataBind on both the non-postback and the postback. I am persisting the state of the grid myself and restoring the state (selectedItem, editItem, sortCommand, etc.). Everything is working just fine EXCEPT the CancelCommand event is not firing. All the other events ARE firing. Here is the CancelCommand: Private Sub dg_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.CancelCommand viewstate.Add("editItem", -1) dg.EditItemIndex = -1 RestoreState() End Sub Private Sub RestoreState() 'Call this method in each DataGrid event handler 'to restore the new grid back to its previous state If Not IsNothing(viewstate.Item("editItem")) Then dg.EditItemIndex = CType(viewstate.Item("editItem"), Integer) End If If Not IsNothing(viewstate.Item("currentPage")) Then dg.CurrentPageIndex = CType(viewstate.Item("currentPage"), Integer) End If If Not IsNothing(viewstate.Item("currentSelection")) Then dg.SelectedIndex = CType(viewstate.Item("currentSelection"), Integer) End If If Not IsNothing(viewstate.Item("currentSort")) Then Dim dv As New DataView(ds.Tables(0)) dv.Sort = CType(viewstate.Item("currentSort"), String) dg.DataSource = dv End If dg.DataBind() End Sub Hi,
This is obvious but have you confirmed that your event handler is set up properly in InitializeComponent? Ken Show quoteHide quote "=?Utf-8?B?U2NvdHQgTS4=?=" <s-mar@nospam.nospam> wrote in message news:<088697EC-2183-4710-81DF-FB5937FE4E6C@microsoft.com>... > I have an asp:DataGrid control with EnableViewState=False. I am calling > DataBind on both the non-postback and the postback. I am persisting the > state of the grid myself and restoring the state (selectedItem, editItem, > sortCommand, etc.). Everything is working just fine EXCEPT the > CancelCommand event is not firing. All the other events ARE firing. > > Here is the CancelCommand: > > Private Sub dg_CancelCommand(ByVal source As Object, ByVal e As > System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.CancelCommand > viewstate.Add("editItem", -1) > dg.EditItemIndex = -1 > RestoreState() > End Sub > > Private Sub RestoreState() > 'Call this method in each DataGrid event handler > 'to restore the new grid back to its previous state > If Not IsNothing(viewstate.Item("editItem")) Then > dg.EditItemIndex = CType(viewstate.Item("editItem"), Integer) > End If > If Not IsNothing(viewstate.Item("currentPage")) Then > dg.CurrentPageIndex = CType(viewstate.Item("currentPage"), Integer) > End If > If Not IsNothing(viewstate.Item("currentSelection")) Then > dg.SelectedIndex = CType(viewstate.Item("currentSelection"), > Integer) > End If > If Not IsNothing(viewstate.Item("currentSort")) Then > Dim dv As New DataView(ds.Tables(0)) > dv.Sort = CType(viewstate.Item("currentSort"), String) > dg.DataSource = dv > End If > dg.DataBind() > End Sub Forgive me, but I'm not sure I know what you mean. What is there to set up?
I didn't have to set anything up to get all the other events to fire correctly (and all the other events do fire). Show quoteHide quote "Ken Charles MCSD" <kenneth.w.char***@gmail.com> wrote in message news:6302a08f.0503041133.7a720156@posting.google.com... > Hi, > > This is obvious but have you confirmed that your event handler is set > up properly in InitializeComponent? > > Ken > > > "=?Utf-8?B?U2NvdHQgTS4=?=" <s-mar@nospam.nospam> wrote in message > news:<088697EC-2183-4710-81DF-FB5937FE4E6C@microsoft.com>... >> I have an asp:DataGrid control with EnableViewState=False. I am calling >> DataBind on both the non-postback and the postback. I am persisting the >> state of the grid myself and restoring the state (selectedItem, editItem, >> sortCommand, etc.). Everything is working just fine EXCEPT the >> CancelCommand event is not firing. All the other events ARE firing. >> >> Here is the CancelCommand: >> >> Private Sub dg_CancelCommand(ByVal source As Object, ByVal e As >> System.Web.UI.WebControls.DataGridCommandEventArgs) Handles >> dg.CancelCommand >> viewstate.Add("editItem", -1) >> dg.EditItemIndex = -1 >> RestoreState() >> End Sub >> >> Private Sub RestoreState() >> 'Call this method in each DataGrid event handler >> 'to restore the new grid back to its previous state >> If Not IsNothing(viewstate.Item("editItem")) Then >> dg.EditItemIndex = CType(viewstate.Item("editItem"), Integer) >> End If >> If Not IsNothing(viewstate.Item("currentPage")) Then >> dg.CurrentPageIndex = CType(viewstate.Item("currentPage"), >> Integer) >> End If >> If Not IsNothing(viewstate.Item("currentSelection")) Then >> dg.SelectedIndex = CType(viewstate.Item("currentSelection"), >> Integer) >> End If >> If Not IsNothing(viewstate.Item("currentSort")) Then >> Dim dv As New DataView(ds.Tables(0)) >> dv.Sort = CType(viewstate.Item("currentSort"), String) >> dg.DataSource = dv >> End If >> dg.DataBind() >> End Sub I think someone has auto-c#-answer turned on. Unless you need to
explicitly bind (or even can) them in vB. You do not need to explicitly bind an eventhandler to it's object in VB.NET
(unless we are talking about custom objects - which we aren't). <awbac***@gmail.com> wrote in message Show quoteHide quote news:1109983878.452251.148030@o13g2000cwo.googlegroups.com... >I think someone has auto-c#-answer turned on. Unless you need to > explicitly bind (or even can) them in vB. > |
|||||||||||||||||||||||