This is a migrated thread and some comments may be shown as answers.

grid refresh after delete

7 Answers 304 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mww
Top achievements
Rank 1
mww asked on 06 Feb 2009, 01:51 PM
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 ?

7 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 09 Feb 2009, 02:11 PM
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.
0
mww
Top achievements
Rank 1
answered on 10 Feb 2009, 10:31 AM
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.
0
Vlad
Telerik team
answered on 10 Feb 2009, 03:29 PM
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.
0
Stuart
Top achievements
Rank 1
answered on 27 Mar 2009, 06:12 PM
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.
0
Shinu
Top achievements
Rank 2
answered on 30 Mar 2009, 09:48 AM
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
0
Stuart
Top achievements
Rank 1
answered on 30 Mar 2009, 09:58 AM
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
0
Sebastian
Telerik team
answered on 30 Mar 2009, 10:50 AM
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.
Tags
Grid
Asked by
mww
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
mww
Top achievements
Rank 1
Vlad
Telerik team
Stuart
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Sebastian
Telerik team
Share this question
or