Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Gridview OnRowUpdating

Posted on 2008-11-19
Medium Priority
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
  • 3
  • 2
LVL 18

Expert Comment

by:David Robitaille
ID: 22994059
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

ID: 22994217

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

David Robitaille earned 2000 total points
ID: 22994340
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

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

Expert Comment

by:David Robitaille
ID: 22994461
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

580 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