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

Accessing Grid GroupByField item

1 Answer 22 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chaitanya Kola
Top achievements
Rank 1
Chaitanya Kola asked on 15 Oct 2008, 04:00 PM
Hi,
I am using GroupByFields in the grid. And I want to access the values in foreach GridItem in the code behind page. how can I access that?
 Following is the code.

Eg:

aspx page:

<

telerik:RadGrid ID="personalGridView" runat="server" AutoGenerateColumns="False"

 

 

AllowPaging="True" GridLines="None" AllowMultiRowSelection="true" ShowGroupPanel="False"

 

 

Skin="Office2007" OnPreRender="personalGridView_PreRender" OnPageIndexChanged="personalGridView_PageIndexChanged">

 

 

<FilterMenu EnableTheming="True">

 

 

<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

 

 

</FilterMenu>

 

 

<PagerStyle Mode="NumericPages" />

 

 

<MasterTableView>

 

 

<GroupByExpressions>

 

 

<telerik:GridGroupByExpression>

 

 

<SelectFields>

 

 

<telerik:GridGroupByField FieldAlias="Name" FieldName="Name" FormatString="" HeaderText="" />

 

 

</SelectFields>

 

 

<GroupByFields>

 

 

<telerik:GridGroupByField FieldName="Name" FieldAlias="Name" FormatString="" HeaderText="" />

 

 

</GroupByFields>

 

 

</telerik:GridGroupByExpression>

 

 

</GroupByExpressions>

 

 

<RowIndicatorColumn>

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</RowIndicatorColumn>

 

 

<ExpandCollapseColumn>

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</ExpandCollapseColumn>

 

 

<Columns>

 

 

<telerik:GridClientSelectColumn CommandName="Select">

 

 

</telerik:GridClientSelectColumn>

 

<

telerik:GridBoundColumn DataField="Amount" HeaderText="Amount">

 

 

 

 

</telerik:GridBoundColumn>

 

</Columns>

 

 

</MasterTableView>

 

 

<ClientSettings AllowDragToGroup="False">

 

 

<Selecting AllowRowSelect="True"></Selecting>

 

 

<Scrolling AllowScroll="True" UseStaticHeaders="True"></Scrolling>

 

 

<ClientMessages DragToGroupOrReorder="Drag to group" />

 

 

</ClientSettings>

 

 

</telerik:RadGrid>

 



CodeBehind:

foreach

(GridItem grdItem in personalGridView.SelectedItems)
{
}

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Oct 2008, 05:28 AM
Hi Chaithanya,

I hope you are trying to access the FieldName in the GroupHeader. If so you can try the following code snipppet.

CS:
   protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridGroupHeaderItem) 
        { 
            GridGroupHeaderItem GroupHeader = (GridGroupHeaderItem)e.Item; 
            string strText = GroupHeader.DataCell.Text; 
            string strFieldName = strText.Split(':')[0];  
        } 
    } 


Thanks
Shinu.
Tags
Grid
Asked by
Chaitanya Kola
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or