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

how can I bind data to DetailTable dynamically.

1 Answer 136 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saadettin
Top achievements
Rank 1
Saadettin asked on 25 Dec 2013, 03:59 PM
Hi. I have a radgrid. It has DetailsTable in MasterTableView. Iwant to load data to detail tables dynamically, but I can not.
I wrote code like below.

 
grdItemRules.DataSource = rules;
 grdItemRules.DataBind();
 
foreach (GridDataItem item in grdItemRules.MasterTableView.Items)
{
          GridTableView tableView = (GridTableView)item.ChildItem.NestedTableViews[0];
 
          tableView.DataSource = rules[item.ItemIndex].RuleItems;
          tableView.DataBind();
}
My code block is like above. Can anyone help me about this? Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 25 Dec 2013, 04:46 PM
Hi Saadettin,

Please note that using DataBind() is not recommended. Performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations.  Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:
Declarative DataSource
Advanced Data Binding

In your specific case, you will need to use programmatic binding:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/programmatic-hierarchy/defaultcs.aspx

In case you want to createyour grid programmatically, please refer to this article:
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html#Section22

If you will change the columns structure dynamically, you should implement this approach:
http://www.telerik.com/help/aspnet-ajax/grid-changing-structure-dynamically.html

Hope this helps.

Regards,
Eyup
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Saadettin
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or