We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Updating a Grid after a button has been clicked.

vossjck
vossjck asked
on
Medium Priority
340 Views
Last Modified: 2012-05-11
I am fairly new to ASP.NET programming, but not new to programming itself.  My problem seems to lie in how to handle the page life-cycle and how to make things happen in the order I need them too.

Here is my problem.  

I have a grid on a page, lets call it grid 2.   When a client selects a row on the grid it updates information in text boxes below.  The user makes changes to these and clicks on a button.  Now the button works fine and updates the underlying SQL database correctly.  My problem is that the grid is not getting updated until later on, when another selection is made.  

The order of operations appears to be ..

Page_Load
Button_Click - update happens here
Page_Render - I rebind the grid here but the grid is not updated on the screen.


The grid and the button are both Telerik Rad Controls.

Is there a way to make this work.  Do I need to use AJAX Panels or something that I am not grasping yet ?

Thank you for any input.
Comment
Watch Question

Commented:
I'm hoping the obvious answer isn't a "can of worms", but in short you need to re-bind the grid right after the update(during the button_click) event.

If you are looking to "only bind once" to simplify code then you may be able to bind in the Page_PreRender event, but this may have implications on dynamic controls you may have added during binding and their associated events.

By the time you get to the Page_Render event all the important details regarding your control's make-up have been made. Unless you have some really important reason, bind after the update during the click event.

Here's an old, but easy to follow article about page life-cycle that may help improve your understanding, although it is an admittedly large and complex model to understand.

http://www.c-sharpcorner.com/UploadFile/Santhi.M/ASP.NETLifeCycle11282005043446AM/ASP.NETLifeCycle.aspx

Author

Commented:
I do the "rebind" right after the button click,  but the grid does not update on the screen.   I've also tried to rebind after the prerender, but the grid still does not update the data displayed on the screen.  Not until another page_load event is triggered.
I am wondering if, because it is a Telerik grid that this has something to do with it.  I had this problem with another Telerik control where certain items were unalbe to change after the page_load.  
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.