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

RadGrid not refreshing after rebind

8 Answers 1607 Views
Grid
This is a migrated thread and some comments may be shown as answers.
tjans
Top achievements
Rank 1
tjans asked on 12 Aug 2010, 02:44 PM
I have a radgrid that ispopulated using the need_datasource event.  We have  a delete button in the grid and when you click the delete, it fires an itemcommand to delete the record and then rebinds the grid.  The record successfully gets deleted, but the grid does not reflect this change.  The stranger part is that when I step through the code using the debugger, the grid DOES refresh correctly.

We've been using telerik grids for a long time now, and never had this problem.  We recently updated to Q1 2010, and I'm wondering if there's some sort of caching going on that we need to explicitly turn off now?

Here's the grid:
<telerik:RadGrid ID="MyGrid" runat="server" AllowPaging="false" AutoGenerateColumns="false" GridLines="None" ShowHeader="True"
                        OnNeedDataSource="MyGrid_NeedDataSource" 
                        OnItemCommand="MyGrid_ItemCommand" 
                        OnItemDataBound="MyGrid_ItemDataBound">
                <MasterTableView AutoGenerateColumns="false" Width="100%" TableLayout="Fixed">
                    <Columns>
                        <telerik:GridBoundColumn UniqueName="Id" DataField="PlanId" HeaderText="Id" Visible="false" />
                        <telerik:GridBoundColumn UniqueName="Name" DataField="Name" HeaderText="Name" />
                        <telerik:GridTemplateColumn>
                            <ItemTemplate>
                                <table cellpadding="0" cellspacing="0" border="0">
                                    <tr>
                                        <td style="border: none; width: 18px; padding: 0;">
                                        <asp:ImageButton ID="DeleteImageButton" runat="server" ToolTip="Delete" 
                                            ImageUrl="App_Themes/PlanAdvisor/Grid/Delete.png"
                                            CommandName="DeleteItem"/>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Right" Width="55px"></HeaderStyle>
                            <ItemStyle HorizontalAlign="Right"></ItemStyle>
                        </telerik:GridTemplateColumn>
                    </Columns>
                    </MasterTableView>
                </telerik:RadGrid>

And here's the code-behind:
Protected Sub MyGrid_ItemCommand(ByVal sender As Object, ByVal e As GridCommandEventArgs) Handles MyGrid.ItemCommand
        If e.Item.ItemType = GridItemType.Item OrElse e.Item.ItemType = GridItemType.AlternatingItem Then
            Dim item As GridDataItem = CType(e.Item, GridDataItem)
           If e.CommandName = "DeleteItem" Then
                DeleteItem(CInt(item("Id").Text))
                MyGrid.Rebind()
            End If
        End If
    End Sub

8 Answers, 1 is accepted

Sort by
0
Jon
Top achievements
Rank 1
answered on 14 Aug 2010, 10:57 PM
Any luck ..?
I'm having the same issue.
thx
0
tjans
Top achievements
Rank 1
answered on 15 Aug 2010, 01:12 PM
No luck yet. I've tried everything I can think of. I am really boggled that when I step throughout the code with the debugger it works. I don't know if there is some new caching stuff in the new release but I'm going to test this in a standalone project with a previous release and see what I can see.
0
Jon
Top achievements
Rank 1
answered on 15 Aug 2010, 02:17 PM
I call Rebind nothing happens...

If I  put Rebind() behind a button click it works.
0
tjans
Top achievements
Rank 1
answered on 24 Aug 2010, 01:31 PM
I had to open a support ticket because Telerik hadn't answered this question on the forums and we are nearing a deadline.  Turns out the answer was very simple.  We previously used Telerik's products almost exclusively with C#.  This product was happening in VB, and it turns out it has nothing to do with us upgrading to a new version of Telerik, it has to do with specifying the ItemCommand event declaratively as well as using the "handles" clause programmatically, and that's why we were seeing different behavior when debugging vs. not debugging.

Obviously, C# doesn't have the handles clause, so we never saw this behavior before.  I removed the handles from the codebehind and sure enough, the grids started rebinding correctly. I hope this helps.
0
Jon
Top achievements
Rank 1
answered on 24 Aug 2010, 01:38 PM
Thanks for the response.. so what is the solution for c#?
0
Tsvetina
Telerik team
answered on 24 Aug 2010, 02:07 PM
Hello Jon,

I assume the issue on your side is different, as Travis' was related to the VB's syntax options for event handling. 

Where are you calling the Rebind() method? How are you performing the item deletion - is it manual or automatic? When you debug the project, do you see that the item is deleted successfully? 

If you prefer, you could open a formal support ticket and send us your code, so we can look through it / debug it locally and find the reason for the incorrect behavior.

Kind regards,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dave
Top achievements
Rank 1
answered on 25 Aug 2010, 01:17 AM
Jon,

Make sure you do not have a rebind in PageLoad.  That was my issue.

Dave
0
Steven
Top achievements
Rank 1
answered on 25 Nov 2014, 03:24 PM
Dave's answer pointed me in the right direction.
I had a ReBind call in Page_Load AND in an button event handler.
It seems the second call to ReBind (in the button handler after changing the datasource) was being ignored.
I put the call to ReBind in Page_PreRender to ensure the button's event handler was the first call to ReBind and all was well :)
Tags
Grid
Asked by
tjans
Top achievements
Rank 1
Answers by
Jon
Top achievements
Rank 1
tjans
Top achievements
Rank 1
Tsvetina
Telerik team
Dave
Top achievements
Rank 1
Steven
Top achievements
Rank 1
Share this question
or