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

[Solved] How to find element in nested grid outside any event

1 Answer 229 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Muskan Gupta
Top achievements
Rank 1
Muskan Gupta asked on 22 Dec 2009, 10:36 AM
Hi,

I have a nested radgrid. I want to update the grid elements on click of Save Button present outside the grid. But I am unable to find the child grid's elements there.
Please help how to get elemnts outside the radgrid event.

Thanks,

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Dec 2009, 11:41 AM
Hello Muskan,

I am not sure, if you want to access detail tables or access a RadGrid nested inside the NestedViewTemplate of the main grid. You can try out either of the following code depending on your scenario:

c#:
code to access the edit row elements of the grid nested inside the NestedViewTemplate of the main grid:
protected void Button1_Click(object sender, EventArgs e) 
    { 
        foreach (GridNestedViewItem nestedItem in RadGrid1.MasterTableView.GetItems(GridItemType.NestedView)) 
        { 
            RadGrid nestedgrid = (RadGrid)nestedItem.FindControl("nestedRadGridID"); 
 
            foreach (GridEditableItem childItem in nestedgrid.MasterTableView.GetItems(GridItemType.EditItem)) 
            { 
                 //access elements here 
                string strtxt = ((TextBox)childItem["BoundColumnUniqueName"].Controls[0]).Text; 
            }          
        } 
    } 

code to access the edit row elements of child grid of the main hierarchical grid:
protected void btnUpdate_Click(object sender, EventArgs e) 
    { 
        foreach (GridDataItem parentItem in RadGrid1.MasterTableView.Items) 
        { 
            GridTableView childtable = (GridTableView)parentItem.ChildItem.NestedTableViews[0]; 
            foreach (GridEditableItem childEditItem in childtable.GetItems(GridItemType.EditItem)) 
            { 
                string strtxt = ((TextBox)childEditItem["BoundColumnUniqueName"].Controls[0]).Text;    
            } 
        } 
    } 

Hope this helps..
Princy.
Tags
Grid
Asked by
Muskan Gupta
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or