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

Find detailsviews in nestedview

4 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
BOS
Top achievements
Rank 1
BOS asked on 03 May 2010, 11:27 AM
How do I loop thru all detailsviews in a nestedview without using the ID's?

<NestedViewTemplate> 
                        <asp:Panel ID="Panel1" runat="server""> 
                            <telerik:RadTabStrip ID="RadTabStrip1" runat="server"   
                                                 MultiPageID="RadMultiPage1"   
                                                 SelectedIndex="0">  
                                <Tabs> 
                                    <telerik:RadTab runat="server" Text="Tab1" PageViewID="RadPageView1">  
                                    </telerik:RadTab> 
                                    <telerik:RadTab runat="server" Text="Tab2" PageViewID="RadPageView2">  
                                    </telerik:RadTab> 
                                    <telerik:RadTab runat="server" Text="Tab3" PageViewID="RadPageView3">  
                                    </telerik:RadTab>                                      
                                </Tabs> 
                            </telerik:RadTabStrip> 
                              
                            <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0" RenderSelectedPageOnly="false">  
                                <telerik:RadPageView ID="RadPageView1" runat="server">  
                                    <asp:SqlDataSource ID="datasource1" runat="server"   
                                                       ConnectionString = ...                                       
                                    </asp:SqlDataSource>                  
                                      
                                    <asp:DetailsView ID="DetailsView1" runat="server"   
                                                    Width="1000px" AutoGenerateRows="False"   
                                                    DataKeyNames="Key1,Key2" DataSourceID="datasource1">  
                                        <FieldHeaderStyle Font-Bold="True" Width="150px"  /> 
                                        <Fields> 
                                            <asp:BoundField DataField="datafield1" HeaderText="Header1:" ReadOnly="True"   
                                                SortExpression="key1" /> 
                                            <asp:BoundField ...  /> 
                                        </Fields> 
                                    </asp:DetailsView> 
                                </telerik:RadPageView> 
                                  
                                <telerik:RadPageView ID="RadPageView2" runat="server">  
                                    <asp:DetailsView ID="DetailsView2" ....                                      
                                    </asp:DetailsView> 
                                </telerik:RadPageView> 
                                  
                                <telerik:RadPageView ID="RadPageView3" runat="server">  
                                    <asp:DetailsView ID="DetailsView3" ....                                      
                                    </asp:DetailsView> 
                                </telerik:RadPageView> 
                            </telerik:RadMultiPage> 
                        </asp:Panel> 
                    </NestedViewTemplate> 

4 Answers, 1 is accepted

Sort by
0
BOS
Top achievements
Rank 1
answered on 03 May 2010, 01:46 PM
I've tried this, but it doesn't work:
    protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        foreach (GridNestedViewItem nestViewItems in RadGrid1.MasterTableView.GetItems(GridItemType.NestedView))  
        {  
            foreach (Control ctrls in nestViewItems.Controls)  
            {  
                if (ctrls is DetailsView)  
                {  
                    DetailsView dv = (DetailsView)ctrls;  
                    do something ...  
                }  
            }  
        }
    } 
0
Yavor
Telerik team
answered on 06 May 2010, 08:27 AM
Hi,

To see more information on the required functionality, please refer to the following topic:

http://www.telerik.com/help/aspnet-ajax/grdtraversingdetailtablesitemsingrid.html

However, please keep in mind that in order for the detail tables to be accessible in such a manner, you would need to set the HierarchyLoadMode to client, so that the inner level is loaded as well.
I hope this information helps.

Regards,
Yavor
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
BOS
Top achievements
Rank 1
answered on 06 May 2010, 10:45 AM
Sorry, but I'm still lost :-)

I need at solution resembling this:
protected void RadGrid1_PreRender(object sender, EventArgs e)        
{        
    foreach (GridNestedViewItem nestViewItems in RadGrid1.MasterTableView.GetItems(GridItemType.NestedView))        
    {        
        foreach (... DetailsView dtvItems ....)        
        {     
            setCssDetailViews(dtvItems);        
        }        
    }     
}      
 

For now I use this solution:
foreach (GridNestedViewItem nestViewItems in RadGrid1.MasterTableView.GetItems(GridItemType.NestedView))  
{  
    DetailsView dv;  
 
    dv = (DetailsView)nestViewItems.FindControl("DetailsView1");  
    setCssDetailViews(dv);  
 
    dv = (DetailsView)nestViewItems.FindControl("DetailsView2");  
    setCssDetailViews(dv);  
 
    ....  
    ..  
It works, but I need a more dynamic solution, in which I doesn't have to address the detailsviews by the IDs.
0
Veli
Telerik team
answered on 11 May 2010, 02:55 PM
Hi BOS,

Try the following too:

protected void Page_PreRender(object sender, EventArgs e)
{
    foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
    {
        if (item.HasChildItems)
        {
            foreach (GridTableView innerView in item.ChildItem.NestedTableViews)
            {
                //innerView is the nested GridTableView for GridDataItem item
            }
        }
    }
}


Sincerely yours,
Veli
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
BOS
Top achievements
Rank 1
Answers by
BOS
Top achievements
Rank 1
Yavor
Telerik team
Veli
Telerik team
Share this question
or