Gridview OnRowUpdating

Posted on 2008-11-19
Last Modified: 2013-11-26

I have a gridview which is populated from a query which concatenates a series of strings. This means that I can't directly edit via the edit button.

I have put an OnRowUpdating event handler which then changes the data progamatically. It seems to work fine except it doesn't reset the cancel/update buttons to edit.

   Protected Sub gwSubAddress_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs)
  ' does lots of stuff with stored procs which update the underlying data
        e.Cancel = True
    End Sub

How do I get the cancel/update buttons to be replaced with the edit button (ie have the effect of clicking the cancel button)

Question by:rchambers
    LVL 18

    Expert Comment

    you should use the OnRowUpdatad that occurs after the update to reset the UI and check for error.
    RowUpdating Does the job
    RowUpdatad  Check the job and update the ui

    Author Comment


    Sorry to be a pain but if I use e.cancel in the rowupdating handler then won't the OnRowUpdated fail to fire?

    If I take the e.cancel out of the RowUpdating how do I reset it before I get the "Updating is not supported by data source 'sdsAddress' unless UpdateCommand is specified" error?
    LVL 18

    Accepted Solution

    i have to contest i dident noticed that. I think the problem is you shortcircuit the update process by using the e.cancel
    The data is binded how? do you use a Object datasource?
    i personally use BLL to handle that situation.
    That has the aventage to isolate the data manipulation from the presentation layer.
    RowUpdating manipulate the brute data and pass the unbinded parameter (if needed)
    The datasource call the update function and throws any error that is not expected.
    RowUpdated  catch the errors
    in the rowupdated i use
    e.ExceptionHandled = True
    e.KeepInEditMode = True
     to keep the form in edit mode in case of error.

    Author Closing Comment

    that worked exactly as I wanted it to, thank you
    LVL 18

    Expert Comment

    Hey, I m glad i could help you! I was felling i was not so clear in that last comment, but i guess you get the essence of what i wanted to say.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now