Home All Groups Group Topic Archive Search About

REPOST: MSDN UNIVERSAL NG SUPPORT, WHERE ARE YOU?

Author
23 Feb 2005 2:25 AM
Scott M.
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.

Any ideas?

Author
23 Feb 2005 8:00 PM
Ken Cox [Microsoft MVP]
What does your CancelCommand handler code look like?

BTW, is the address s-mar@nospam.nospam registered with MSDN's support?


Show quoteHide quote
"Scott M." <s-mar@nospam.nospam> wrote in message
news:OsCOf5UGFHA.1836@tk2msftngp13.phx.gbl...
>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.
>
> Any ideas?
>
Author
23 Feb 2005 8:41 PM
Scott M.
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

And yes, my email address is registered with MSDN.


Show quoteHide quote
"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@sympatico.ca> wrote in message
news:uH4EeJeGFHA.2156@TK2MSFTNGP09.phx.gbl...
> What does your CancelCommand handler code look like?
>
> BTW, is the address s-mar@nospam.nospam registered with MSDN's support?
>
>
> "Scott M." <s-mar@nospam.nospam> wrote in message
> news:OsCOf5UGFHA.1836@tk2msftngp13.phx.gbl...
>>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.
>>
>> Any ideas?
>>
>