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

Extracting primary key value for parent item in hierarchy on ItemDataBound

2 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gino Suarez
Top achievements
Rank 1
Gino Suarez asked on 30 Oct 2009, 08:41 PM
Hi,

Im triying to extract the primary key value for parent groupfooter item when i click on it (my gridfooteritems are links). I have two levels of groups

protected void tk_Grid_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
    if (e.Item is GridGroupFooterItem) 
        { 
 
            GridGroupFooterItem gridfooteritem = e.Item as GridGroupFooterItem;                         
 
            if (double.Parse(gridfooteritem["Enero"].Text) == 0) gridfooteritem["Enero"].Text = ""
            gridfooteritem["Enero"].Text = "<a class=linkstotal href=frmAnexoBalance.aspx?Periodo=ENERO&MesID=1&GGPPID=0>" + gridfooteritem["Enero"].Text + "</a>"

Regards Gino

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 02 Nov 2009, 06:08 AM
Hello Gino,

I suppose you are trying to pass the key value of the parent item as a parameter for the GridGroupFooterItem of your detail table. If so, here's an example of how to get this done:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" OnItemDataBound="RadGrid1_ItemDataBound">           
     <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="FirstName" Name="Master">                  
          <DetailTables>                      
               <telerik:GridTableView ShowGroupFooter="true" Name="Detail"  DataSourceID="SqlDataSource2" runat="server"
                   <GroupByExpressions> 
                     .... 
                   </GroupByExpressions> 

c#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
       if (e.Item is GridGroupFooterItem && e.Item.OwnerTableView.Name == "Detail"
        { 
            GridGroupFooterItem groupFooterItem = (GridGroupFooterItem)e.Item; 
            GridDataItem parentItem = (GridDataItem)groupFooterItem.OwnerTableView.ParentItem; 
            string strtxt = parentItem.GetDataKeyValue("FirstName").ToString(); 
        } 
    } 

Thanks
Princy.
0
Gino Suarez
Top achievements
Rank 1
answered on 02 Nov 2009, 10:46 PM
Hi Princy, thanks for your answer, but i don`t use nested tables, i use just one table and obtaing the hierchly mode trought "outlook grouping mode". what i need no know is
 when i click on one of the groupfooter items, get the parent from this groupfooter item. thanks

<MasterTableView  CellSpacing="0" ShowGroupFooter="true" AllowMultiColumnSorting="true" ShowFooter="true">                                             
                                            <Columns>                                                                                                                                                     
                                                                                                                                                                                                                                                  
                                                <telerik:GridBoundColumn    DataField="Apertura" HeaderText="Apertura" Aggregate="Sum" HeaderStyle-HorizontalAlign="Right" 
                                                                            FooterAggregateFormatString="{0:g}" FooterStyle-Font-Bold="true" Groupable="false"
                                                                             <HeaderStyle HorizontalAlign="Right" /> 
                                                                             <ItemStyle CssClass="gridtext" HorizontalAlign="Right" /> 
                                                                     <FooterStyle HorizontalAlign="Right" /> 
                                                </telerik:GridBoundColumn> 
 
<GroupByExpressions> 
                                                <telerik:GridGroupByExpression> 
                                                    <GroupByFields>                                                                                                         
                                                        <telerik:GridGroupByField FieldName="NombreTipoCuenta" FormatString="{0:g}" />                                                         
                                                    </GroupByFields> 
                                                    <SelectFields> 
                                                        <telerik:GridGroupByField FieldName="NombreTipoCuenta" HeaderText="Cuenta" /> 
                                                    </SelectFields> 
                                                     
                                                </telerik:GridGroupByExpression> 
 
                                                <telerik:GridGroupByExpression> 
                                                    <GroupByFields>                                                         
                                                        <telerik:GridGroupByField FieldName="NombreFormatoBalance" /> 
                                                    </GroupByFields> 
                                                    <SelectFields> 
                                                        <telerik:GridGroupByField FieldName="NombreFormatoBalance" HeaderText="Tipo" /> 
                                                    </SelectFields> 
                                                </telerik:GridGroupByExpression> 
                                            </GroupByExpressions> 
 

Best Regards Gino

Tags
Grid
Asked by
Gino Suarez
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Gino Suarez
Top achievements
Rank 1
Share this question
or