Gridview OnRowUpdating

Hi

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)

Thanks
rchambersAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David RobitailleAnalyst ProgrammerCommented:
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
0
rchambersAuthor Commented:
Thanks

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?
0
David RobitailleAnalyst ProgrammerCommented:
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rchambersAuthor Commented:
that worked exactly as I wanted it to, thank you
0
David RobitailleAnalyst ProgrammerCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.