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

[Solved] Tab within DataGrid

3 Answers 137 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mk
Top achievements
Rank 1
mk asked on 01 Mar 2010, 12:55 AM
I have a datagrid that gets populated from a datasource.  Using an ID passed from the datagrid, I am trying to generate values in tabstrip based on the selected id.  Any ideas how that can be done.  Any small example for the same ?

Thanks

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Mar 2010, 10:50 AM
Hi,

You can access  the selected  item value using the  code snippet below:
 string categoryName= RadGrid1.SelectedValues["CategoryName"].ToString();

In case you want to access the RadTabstrip for each item 
  foreach (GridDataItem dataItem in RadGrid1.SelectedItems) 
        { 
            string selectedValue = dataItem.GetDataKeyValue("CategoryName").ToString(); 
            RadTabStrip tabStrip = (RadTabStrip)dataItem.FindControl("RadTabStrip1"); 
        } 


Hope this helps.

Thanks,
Princy
0
mk
Top achievements
Rank 1
answered on 01 Mar 2010, 03:34 PM
Thanks Princy for the snippet.

This is how my structure is defined in aspx.

<RadGrid1>
  <NestedViewTemplate>
<RadGrid2>
    <NestedViewTemplate>
        <RadTabStrip ..... />
    </NestedViewTemplate>
</RadGrid2>
</NestedViewTemplate>
</RadGrid1>

So, what method should I use to populate the child control ( RadGrid2 and its child contol RadTabStrip ) .  Is there a sample out there somewhere that I can look at .

Also, is it possible to completely build this structure programmatically.  I was able to build a similar structure with RadGrid ( DetailTable ) but was unable to add RadTabStrip control and had to only work with RadGrid.


Thanks again for the quick response.
0
Princy
Top achievements
Rank 2
answered on 02 Mar 2010, 06:02 AM
Hi,

Please try the code snippet below to access the nested RadGrid and RadTabstrip and set the datasource accordingly:

 protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if(e.CommandName=="ExpandCollapse"
        { 
            GridDataItem dataItem=(GridDataItem)e.Item; 
            GridItem[] nestedViewItems = dataItem.OwnerTableView.GetItems(GridItemType.NestedView); 
            foreach (GridNestedViewItem nestedViewItem in nestedViewItems) 
            { 
                RadGrid grid2 = (RadGrid)nestedViewItem.FindControl("RadGrid2"); 
                GridItem[] nestedViewItems1 = grid2.MasterTableView.GetItems(GridItemType.NestedView); 
                foreach (GridNestedViewItem nestedViewItem1 in nestedViewItems1) 
                { 
                    RadTabStrip RadTabStrip2 = (RadTabStrip)nestedViewItem1.FindControl("RadTabStrip2"); 
                    RadTab tab = new RadTab(dataItem.GetDataKeyValue("CategoryName").ToString()); 
                    RadTabStrip2.Tabs.Add(tab); 
                } 
            } 
        } 
    } 
             


Hope this helps.

Thanks.
Princy
Tags
Grid
Asked by
mk
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
mk
Top achievements
Rank 1
Share this question
or