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

How to refresh RadGrid after updating data in ItemDataBound event?

1 Answer 323 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Le Duc Hieu
Top achievements
Rank 2
Le Duc Hieu asked on 29 Apr 2011, 04:44 AM
hi people!

i wanna rebind my RadGrid after updating data to database, everything works well except that the RadGrid cant rebind data after the action completed, here is my source code.

        protected DataClasses1DataContext context = new DataClasses1DataContext();

        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
            {
                if ((item["Name"].FindControl("Name") as Label).Text == "Action")
                {
                    var group = (from g in context.Groups where g.Name == "Action" select g).Single();
                    group.Note = "note!";
                    context.SubmitChanges();
                    item.Enabled = false;
                }
            }    
            // i cant call back Rebind() method in RadGrid here because RadGrid does not allow while databinding
        }
i wanna show my data that has been updated in this event but havent still found out the ways to do it yet.
anyone can handle this problem please help me to fix it.

thanks in advance.

kind regards.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 05 May 2011, 12:03 AM
Hello Le Duc Hieu,

I strongly recommend that you move this code somewhere else - on Page_PreRender for instance. Using your current approach, you will traverse the whole items collection every time when a grid item is bound. This is not needed and will cause slowdown.

Best regards,
Daniel
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Le Duc Hieu
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Share this question
or