473,322 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Gridview: How change view to normal state after RowUpdating?

I have some custom rowupdating code in my gridview.

The user clicks edit, edits the record, clicks update and it runs my code.

The code runs fine but the row is still in an 'update' mode. How can I
change it back to 'normal' mode, as if they clicked cancel?

e.cancel = true doesnt seem to work.

Thanks.
Nov 19 '08 #1
4 6403
After you update the row, set the grid's edit index to -1 and rebind your grid.

GridView1.EditIndex = -1;
GridView1.Bind();

"Bobby Edward" wrote:
I have some custom rowupdating code in my gridview.

The user clicks edit, edits the record, clicks update and it runs my code.

The code runs fine but the row is still in an 'update' mode. How can I
change it back to 'normal' mode, as if they clicked cancel?

e.cancel = true doesnt seem to work.

Thanks.
Nov 19 '08 #2
I've tried that as well as other ways...

Protected Sub gvSubusers_RowUpdated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewUpdatedEventArgs ) Handles
gvSubusers.RowUpdated

e.KeepInEditMode = False

gvSubusers.EditIndex = -1

End Sub

This gv is bound to an objectdatasource. But I don't think that should
matter. Also it's in an updatepanel.
Nov 19 '08 #3
Add the following to the last line of your event method:
gvSubusers.DataBind();

This will cause the grid to refresh and it will see that it is not in edit
mode and the row will be back to normal mode.

"Bobby Edward" wrote:
I've tried that as well as other ways...

Protected Sub gvSubusers_RowUpdated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewUpdatedEventArgs ) Handles
gvSubusers.RowUpdated

e.KeepInEditMode = False

gvSubusers.EditIndex = -1

End Sub

This gv is bound to an objectdatasource. But I don't think that should
matter. Also it's in an updatepanel.
Nov 19 '08 #4
I tried that too but it didn't work. So I just the good ole'
response.redirect back to the page. :(
Nov 19 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Yeah | last post by:
I have a multiple choice quiz where I would like to use CSS to change the color of the answers upon clicking them. I would like to present the right and wrong answers up front, rather than direct...
0
by: whatchu | last post by:
VS .NET 2003 Is it possible to get a form's FormWindowState.Normal coordinates that Windows has saved, WHILE the form is Maximized? i.e. click the restore box on a maximized form, and it goes...
1
by: Prozon | last post by:
Hi! I have an asp.net page with a gridview. One "columnfield" in the grid contains boolean values. Is there a nice way to map this values to a string depending on the value. I.e I want to display...
3
by: John Daly | last post by:
I am using a Gridview to display a phone directory, with paging on. I have a link button that a user clicks to add a new record, which reloads the page, sets the visble property to false on the...
1
by: mgonzales3 | last post by:
What is best method to create a nested gridview? Thanks
5
by: Cindy Lee | last post by:
I want to have a button to view top 5 and toggle to view all on my gridview. Can this be done using paging? I don't want to show page 1, 2, 3. Just the top 5 or all. Or am I going to have to...
3
by: rsdev | last post by:
Hi, I am creating a WYSIWIG CMS and when the user clicks on a linkbutton in an update panel, I would like to change the mode of the gridview to edit. I am confused about how to make a...
2
by: inga2005 | last post by:
Hi! I have a very strange problem. I populate a gridview control with a list containing swedish cities and that looks fine. But once I click on one of the rows in the gridview to select that...
2
by: Ananthu | last post by:
Hi, I have a gridview with paging option. I want to maintain the state of the checkbox column in gridview for each page. I used vb.net coding. I used the following link for this purpose, ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.