Updating a Grid after a button has been clicked.

Posted on 2011-04-20
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 ..

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.
Question by:vossjck
    LVL 20

    Expert Comment

    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.
    LVL 2

    Author Comment

    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.  
    LVL 20

    Accepted Solution

    I'm sorry you could post your code, but alas the telerik controls are not in my repertoire. I cursory research foray tells me the telerik grid is a very specialized beast. If I were you I'd post my issue in the telrik forum or repost this question clarifying that you are using a telerik grid(preferably in the subject heading) and with some code samples.

    Radgrid not updating ex.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Suggested Solutions

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    779 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

    18 Experts available now in Live!

    Get 1:1 Help Now