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

[Solved] Rad Grid not displaying changes to datasource dataset

9 Answers 559 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Acadia
Top achievements
Rank 1
Iron
Acadia asked on 12 Feb 2009, 09:51 PM
I have a Rad Grid where the user can create empty rows to populate and save them to the database.  The user can create multiple blank rows and cancel them accordingly.  My code successfully creates the blank rows and maintains existing rows by populating a dataset with the existing rows then creating new empty rows in that same dataset, then rebinds the dataset. 

The problem is that even though after the Cancel icon is clicked and that cancelled row is deleted from the datset, and the grid is rebound and the grid shows the proper rows in debug (the deleted row is gone), for some reason when the page is redisplayed that row that was deleted from the dataset is still there.  It's no longer in Edit Mode but it lingers in the grid like some Ghostly Row of Debugging Past.  I can't find a way to get rid of that row.  But it is defintiely not in the dataset after the last rebind.

The Grid is ajaxed.  Could this be the issue?  How can I force the refresh of the grid after the databind?  This has become a huge time consuming problem and I really hope I can resolve this soon.

Thanks for your help

9 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 16 Feb 2009, 04:43 PM
Hello Acadia,

Thank you for the explanation.

Generally speaking, if you remove the empty record(s) from the underlying grid source and refresh the control invoking its Rebind() method, it should reflect the latest changes in its row structure. Can you please verify that the items are deleted in the source and the grid is rebound afterwards?

Furthermore, if the control is ajaxified through RadAjaxManager, make sure it is marked as an updated control through the respective RadAjaxManager setting.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Sphengle
Top achievements
Rank 1
answered on 25 Nov 2009, 01:59 PM
Seems I am having a similar problem.  Initally I thought it was to do with Ajax but upon removing the Ajax panel I still get the same result but only when there is a filter on the grid.

In my case the record is deleted from a Dataset in the ItemCommand event (after clicking a button in the row).  Then a call to grid.ReBind() is made.  Now this seems to work fine as long as the grid doesn't have a filter on it.  As soon as a filter is applied to a column in the grid I have to press the delete button twice for the record to be removed from the grid.  I have confirmed that the record is actually removed on the first click.

0
Sebastian
Telerik team
answered on 25 Nov 2009, 02:51 PM
Hello Sphengle,

Can you please confirm that you are using advanced binding with NeedDataSource event handling in this case? In case you use simple binding with DataBind() calls, consider switching to this type of binding to see whether this addresses the issue.

Regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sphengle
Top achievements
Rank 1
answered on 25 Nov 2009, 03:11 PM
Hi Sebastion

Not sure I understand what "advanced" data binding is but we always handle the NeedDataSource event.  I can confirm that this event is triggered and handled after removing the record from the DataSet.  Not sure why the problem only occurs when there is a filter on the grid.



0
Sphengle
Top achievements
Rank 1
answered on 25 Nov 2009, 03:22 PM
Hi Sebastion

I've just found another clue.  This time I was able to reproduce the problem without filtering.

If I go to page 3, say, then try to delete the record it also fails to refresh the grid.  The grid is only refreshed when I delete something on the first page.


0
Sebastian
Telerik team
answered on 27 Nov 2009, 09:28 AM
Hello Sphengle,

This is indeed strange and unfortunately from the provided details so far I cannot say for certain what might be the exact cause of it.

Can you double-check that you do not have any DataBind() calls for the grid and share with us the html markup and code-behind of the page which hosts the control (using the Format Code Block dialog from the forum editor)? Thus I will do my best to provide more-to-the-point answer.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sphengle
Top achievements
Rank 1
answered on 27 Nov 2009, 10:09 AM
Hi Sebastion

I can't give you all the source due to the confidential nature of the application - here are the relevant snippets....

The grid with all columns removed apart from the one that triggers the removal of the record from the dataset. 

<telerik:RadGrid ID="rdgMyOrders" runat="server" AutoGenerateColumns="False" AllowFilteringByColumn="True" ShowFooter="True" 
        AllowSorting="True" AllowPaging="True" PageSize="13" GridLines="Horizontal"   
        OnNeedDataSource="rdgMyOrders_NeedDataSource" OnItemCommand="rdgMyOrders_ItemCommand" OnItemCreated="rdgMyOrders_ItemCreated" OnInit="rdg_Init" OnItemDataBound="rdgMyOrders_ItemDataBound">  
    <MasterTableView DataKeyNames="OrderID" Width="100%">  
        <PagerStyle Mode="NextPrevAndNumeric" />   
        <Columns> 
           
            <telerik:GridTemplateColumn AllowFiltering="False" Visible="False" UniqueName="AuthoriseLink">  
                <ItemTemplate> 
                    <asp:ImageButton ID="lnkAuthorise" runat="server" CommandName="Authorise" ToolTip="Authorise" ImageUrl="~/App_Themes/Default/images/icons/OK.gif" style="border:0px;" /> 
                </ItemTemplate> 
                <ItemStyle Width="25px" /> 
                <HeaderStyle Width="25px" /> 
            </telerik:GridTemplateColumn> 
           
              
        </Columns> 
    </MasterTableView>          
    <ClientSettings> 
        <Scrolling AllowScroll="false" UseStaticHeaders="True" ScrollHeight="400px" SaveScrollPosition="true"/>  
        <ClientEvents OnGridCreated="GridCreated" /> 
   </ClientSettings>       
</telerik:RadGrid> 
</div> 
</telerik:RadAjaxPanel> 


Here's the code that is triggered on clicking the button....

protected void rdgMyOrders_ItemCommand( object source, Telerik.Web.UI.GridCommandEventArgs e )  
        {  
            switch ( e.CommandName )  
            {  
                ....  
                  
                case "Authorise":  
                    AuthoriseOrder( e.Item.OwnerTableView.DataKeyValues[ e.Item.ItemIndex ][ "OrderID" ].ToString() );  
                    _orderDataset.Tables[ 0 ].Rows[ e.Item.ItemIndex ].Delete();  
                    _orderDataset.AcceptChanges();                      
                    rdgMyOrders.Rebind();  
                    break;  
                      
                ......  
            }  
        } 

The rebind triggers this....

protected void rdgMyOrders_NeedDataSource( object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e )  
{  
    rdgMyOrders.DataSource = _orderDataset;  

I have confirmed via the debugger that the record is actually removed from the Dataset prior to rebinding.

As mentioned previously this grid refreshes OK as long as I am on the first page of data and no columns are being filtered.

0
Sphengle
Top achievements
Rank 1
answered on 27 Nov 2009, 10:26 AM
Another clue....

I have confirmed by debugging that the record is removed from the databaset prior to the rebind (see code above) - however I put breakpoints in the ItemDataBind event and it would appear to think that the removed record is still there. 

This is what I did.  I applied a column filter such that only two records were displayed (the dataset contains about 370 records) with paging set to 13.  I then "authorised" one record which removes it from the dataset.  But two ItemDataBind events occurs - one of which being the removed record?

Is the filtered view of the data some how cached by the grid?

0
Sebastian
Telerik team
answered on 02 Dec 2009, 03:30 PM
Hello Sphengle,

From the markup of the grid I see that it is wrapped inside RadAjaxPanel. Does moving it outside of the panel or setting EnableAJAX = false for it fixes the erroneous behavior? Furthermore, verify that you do not ajaxify the grid via RadAjaxManager setting since it already resides in ajax panel.

If the issue remains, the best means to progress in our investigation is to prepare a simplified working version of your project (and send it enclosed to a regular support ticket. I will debug it locally and will get back to you with my findings.

By the way, my name is Sebastian, not Sebastion.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Acadia
Top achievements
Rank 1
Iron
Answers by
Sebastian
Telerik team
Sphengle
Top achievements
Rank 1
Share this question
or