GridView: Cancel Update using vb Code.

Discussion in 'ASP .Net Web Controls' started by Ed Warren, Apr 10, 2007.

  1. Ed Warren

    Ed Warren Guest

    I have a gridview. It has the duty edit button.
    when I click the update button
    the updating event fires
    (all is as I want)
    instead of doing an update, I need to capture the new data --done that using
    the event e variable. (still ok)

    However, here is the question. After I'm through, I need to stop the update
    I really do not need finish the update, but I do need to return to the form
    with the gridview no longer in the edit mode. (I need to cancel the update
    using code).

    After a few hours of searching, coding, and frustration --- I'm
    stupid/stumped. This should be easy, so I'm missing something (GCE).

    Thanks,
    --
    Ed Warren
    Ed Warren, Apr 10, 2007
    #1
    1. Advertising

  2. http://msdn2.microsoft.com/en-us/library/system.componentmodel.canceleventargs.cancel(VS.80).aspx

    Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
    GridViewUpdateEventArgs)
    'e.NewValues("Something") = "Something"
    e.Cancel = False
    End Sub

    --
    HTH,
    Phillip Williams
    http://mcts-study-practices.com/
    http://www.webswapp.com


    "Ed Warren" wrote:

    > I have a gridview. It has the duty edit button.
    > when I click the update button
    > the updating event fires
    > (all is as I want)
    > instead of doing an update, I need to capture the new data --done that using
    > the event e variable. (still ok)
    >
    > However, here is the question. After I'm through, I need to stop the update
    > I really do not need finish the update, but I do need to return to the form
    > with the gridview no longer in the edit mode. (I need to cancel the update
    > using code).
    >
    > After a few hours of searching, coding, and frustration --- I'm
    > stupid/stumped. This should be easy, so I'm missing something (GCE).
    >
    > Thanks,
    > --
    > Ed Warren
    Phillip Williams, Apr 10, 2007
    #2
    1. Advertising

  3. Ed Warren

    Ed Warren Guest

    Thanks for the note Phillip, but I've tried that, the code you have shown
    cancel's the update okay, but it returns the row still in the edit state.

    I found an answer
    I set the
    grid.datasourece.editrowindex = -1

    then called the

    e.cancel
    That worked.


    Ugh!! now where could I find something that simple!
    --
    Ed Warren


    "Phillip Williams" wrote:

    > http://msdn2.microsoft.com/en-us/library/system.componentmodel.canceleventargs.cancel(VS.80).aspx
    >
    > Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
    > GridViewUpdateEventArgs)
    > 'e.NewValues("Something") = "Something"
    > e.Cancel = False
    > End Sub
    >
    > --
    > HTH,
    > Phillip Williams
    > http://mcts-study-practices.com/
    > http://www.webswapp.com
    >
    >
    > "Ed Warren" wrote:
    >
    > > I have a gridview. It has the duty edit button.
    > > when I click the update button
    > > the updating event fires
    > > (all is as I want)
    > > instead of doing an update, I need to capture the new data --done that using
    > > the event e variable. (still ok)
    > >
    > > However, here is the question. After I'm through, I need to stop the update
    > > I really do not need finish the update, but I do need to return to the form
    > > with the gridview no longer in the edit mode. (I need to cancel the update
    > > using code).
    > >
    > > After a few hours of searching, coding, and frustration --- I'm
    > > stupid/stumped. This should be easy, so I'm missing something (GCE).
    > >
    > > Thanks,
    > > --
    > > Ed Warren
    Ed Warren, Apr 10, 2007
    #3
    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. Replies:
    0
    Views:
    1,133
  2. Vincent
    Replies:
    2
    Views:
    675
    gustmg
    Feb 10, 2009
  3. das

    dropdownlist inside a gridview with Edit,Update,Cancel

    das, Sep 18, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    1,017
  4. Marco Liedekerken
    Replies:
    0
    Views:
    1,051
    Marco Liedekerken
    Nov 8, 2006
  5. Gerry Cook

    Gridview - Edit,Update,Cancel doesn't work

    Gerry Cook, Oct 3, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    442
    Gerry Cook
    Oct 3, 2006
Loading...

Share This Page