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

Second RadGrid nested inside Main RadGrid's From Template

1 Answer 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Danielle Mascher
Top achievements
Rank 1
Danielle Mascher asked on 06 May 2010, 09:38 AM
Good morning

I have a main Radgrid that uses Advanced data binding and has uses a form template to add/edit grid users. This all works perfectly.

Inside the form template, I have RadTabstrip and Multipage.

The first page view contains the fields neccessary to add/ update grid items and in the second page view I have a second Radgrid that displays additional information linked to the selected user.

THe second RadGrid gets bound in the main RadGrid's itemdatabound event handler and I need to bind the second RadGrid using advanced data binding as i need to implement paging.

So the issue I am having, is that I cannot access the second RadGrid control inside its needdatasource event handler as it's inside my first grid's from template.

Can you please show me how to access this control or show me a better way of binding the second RadGrid that would still allow for paging.

Thank you!

Danielle
 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 May 2010, 11:40 AM
Hello Danielle,

The source parameter in NeedDataSource event refers to the grid which invokes the event. You can directly access the RadGrid control from the 'source' as shown below.

C#:
 
    protected void RadGrid2_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
    { 
        RadGrid grid = (RadGrid)source; // Get reference to grid 
        GridDataItem item = (GridDataItem)(grid.NamingContainer as GridEditFormItem).ParentItem;  // Get the mastertableview item 
        string id = item["CustomerID"].Text; // Get the value 
        grid.DataSource = getDataTable(id); // Populate the grid according to parent item cell value, (call the method by passing value)
    } 

The code shows how to get the parent item value and populate the grid based on that value. I hope this would help you.

Happy coding,
Princy.
Tags
Grid
Asked by
Danielle Mascher
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or