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

RadGrid with dynamic DataSource

1 Answer 319 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Douglas
Top achievements
Rank 1
Douglas asked on 21 Feb 2012, 11:10 AM

I have a RadGrid that needs to have dynamic DataSource. The grid will have an A to Z index, where only names started by selected alphabeth is displayed.

When the grid is first loaded, the datasource is by default:

<asp:LinqDataSource ID="ldsMember" ContextTypeName="RedBuckDataContext" TableName="RB_Members" OrderBy="FIFOType" runat="server" />

It loads fine, I can edit, insert and delete columns with no problems.

When an A-Z linkbutton is clicked, the grid's datasource is changed:

                using (RedBuckDataContext rbdc = new RedBuckDataContext())
                {
                    var member = (from m in rbdc.RB_Members
                                  where m.Name.StartsWith(lbAlp.CommandArgument)
                                  select m);

                    rgMember.DataSource = member.ToList();
                }

        rgMember.DataSourceID = null;
        rgMember.DataBind();

The grid displays only data starated with the selected alphabeth, which is good!

The problem is, when I click "Edit" to modify the data, the grid does not display anything. The rows displayed were gone. It is like the datasource has been resetted.

Can anyone please help me on this?

Cheers,

Andry

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 23 Feb 2012, 04:56 PM
Hi Douglas,

Please note that when using simple data-binding you need to assign the data source and rebind the grid after any data operation such as paging, sorting, editing, and so on.

As a different option, you can cosider switching to using advanced data-binding to have this rebinding handled by the RadGrid control implicitly:
http://www.telerik.com/help/aspnet-ajax/grid-advanced-data-binding.html

Regards,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Douglas
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or