grid refresh after delete

8 posts, 0 answers
  1. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 06 Feb 2009 Link to this post

    I have a radcombo and a radgrid on a webpage.  Both are ajax enabled (with RadAjaxManagerProxy)
    If a user selects a value in the radcombo that is different to the combo's current value, I need to delete all the entries in the grid.  Ive used this code

    protected void RadComboBoxType_SelectedIndexChanged1(object o, RadComboBoxSelectedIndexChangedEventArgs e)  
            {  
                if (e.OldValue != e.Value)  
                {  
                    DeleteGenres();  
                }  
            }  
     
            private void DeleteGenres()  
            {  
                long aid;  
                bool ok = long.TryParse(this.HiddenArtistID.Value, out aid);  
                if (ok)  
                {  
                    string _res = artistgenremanager.DeleteArtistGenres(aid);  
                    if (!string.IsNullOrEmpty(_res))  
                    {  
                        RadGridGenreCategories.Controls.Add(new LiteralControl("Unable to delete genres and categories. Reason: " + _res));  
                    }  
                    else  
                    {  
                        RadGridGenreCategories.Rebind();  
                    }  
                }  
            } 
    Ive set postback = true in the combo so the SelectedIndexChanged event gets fired, which in turn calls the DeleteGenres method.  This works well, and the data displayed in the grid is deleted from the uderlying database.  The problem is that the grid contents dont get refreshed, so the grid still shows the rows.  If I hit the refresh button in the grid toolbar, the the grid contents disappear.  I want the refresh to be part of the deletion method and I expected Rebind() to work.  How Can I achieve this functionality ?
  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 09 Feb 2009 Link to this post

    Hello Mark,

    I guess you do not have proper "RadAjaxManagerProxy" settings.
    Add in "RadAjaxManagerProxy.AjaxSettings" combo box as request initiator and RadGrid as updated control. Thus when SelectedIndexChanged occurs RadGrid will be updated after Rebind is called.

    I hope this helps.

    Best wishes,
    Nikolay
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 10 Feb 2009 Link to this post

    Im the RADAJAXManagerProxy, I have this entry

    <telerik:AjaxSetting AjaxControlID="RadComboBoxType">  
                <updatedcontrols> 
                    <telerik:AjaxUpdatedControl ControlID="RadComboBoxType" /> 
                    <telerik:AjaxUpdatedControl ControlID="RadGridGenreCategories"   
                        LoadingPanelID="RadAjaxLoadingPanel1" /> 
                </updatedcontrols> 
            </telerik:AjaxSetting> 

    after the SelectedIndexChanged event fires, the deletion code is executed, but the grid still isnt updated.
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 10 Feb 2009 Link to this post

    Hello mark,

    You will need to set the grid to update itself.

    Regards,
    Vlad
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Stuart
    Stuart avatar
    2 posts
    Member since:
    Mar 2009

    Posted 27 Mar 2009 Link to this post

    How do you set the grid to update by itself. We are having this same problem too.  We are actually firing the event from a button click but the grid does not update even though the dataset is updated and reloaded.
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Mar 2009 Link to this post

    Hi Stuart,

    Try disabling the Ajax and see whether the Grid is getting updated. If it is working try adding the Ajax settings properly.

     
    <telerik:AjaxSetting AjaxControlID="Button1">   
                <updatedcontrols>  
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"  LoadingPanelID="RadAjaxLoadingPanel1" />     
                </updatedcontrols>  
            </telerik:AjaxSetting> 

    Shinu
  8. Stuart
    Stuart avatar
    2 posts
    Member since:
    Mar 2009

    Posted 30 Mar 2009 Link to this post

    sorry, what do you mean disable it. Can you be a little more specific on what we need to try.  Where do we need to disable it?

    We have identified now that the grid works just fine if we bing it directly to an sqldatabase but if we bind it to our own dataset and add a record to the grid the grid does not refresh until we press the refresh button or change to an page in the grid. 

    Are we missing something, do you have examples of how we can do this please.

    Thanks
  9. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 30 Mar 2009 Link to this post

    Hello Stuart,

    Can you please verify that you are using advanced binding with NeedDataSource handling for your grid?
    This should ensure that the control will be bound implicitly when some built-in operations take place and will be refreshed explicitly when you invoke its Rebind() method. More information on the lifecycle of our web grid can be gathered from these sources:

    http://www.telerik.com/help/aspnet-ajax/grdeventsequence.html
    http://www.telerik.com/help/aspnet-ajax/grdcommandsthatinvokerebindimplicitly.html

    Regards,
    Sebastian
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017