We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how to find lable control in grid grouping control of item template

Thread ID:

Created:

Updated:

Platform:

Replies:

117173 Aug 28,2014 04:33 AM UTC Sep 2,2014 07:05 AM UTC ASP.NET Web Forms (Classic) 1
loading
Tags: GridGroupingControl
mohsin
Asked On August 28, 2014 04:33 AM UTC

how to find lable control in grid grouping control of item template  .please help me

Silambarasan I [Syncfusion]
Replied On September 2, 2014 07:05 AM UTC

Hi Mohsin,

 

Thank you for using Syncfusion Products.

 

We are glad to let you know that your requirement “To find label control in grid grouping control of item template” can be achieved by two ways, either by using Prerender event or by using button click event.  Please refer the below code snippets.

 

CODE SNIPPET:

 

[ASPX]

 

<Syncfusion:GridGroupingControl ID="GridGroupingControl1" runat="server" ShowGroupDropArea="False" AutoFormat="Office 2007 Blue" Width="500"

DataSourceCachingMode="ViewState">

<TableDescriptor AllowFilter="False" AllowNew="false" AllowEdit="false">

<Columns>

<syncfusion:GridColumnDescriptor MappingName="OrderID">

<ItemTemplate>

<asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Size="11px" Text="<%#GetId(Container)%>" />

</ItemTemplate>

</syncfusion:GridColumnDescriptor>

//...

</Columns>

</TableDescriptor>

</Syncfusion:GridGroupingControl>

<asp:Button ID="Button1" runat="server" Text="Click here!" Width="80px" OnClick="getLabelObject"/>

 

 

[ASPX.CS]

 

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

//Bind data to GridGroupingControl.

GetData();

//Prerender event for finding label control in Page_Load

this.GridGroupingControl1.PreRender += GridGroupingControl1_PreRender;

}

}

 

//Find label control in Page_Load

private void GridGroupingControl1_PreRender(object sender, EventArgs e)

{

foreach (TableRow row in this.GridGroupingControl1.TopLevelTable.Rows)

{

GridRow gvr = row as GridRow;

if (gvr.DisplayElement.Kind == Syncfusion.Grouping.DisplayElementKind.Record)

{

Label cb = gvr.Cells[1].FindControl("Label2") as Label;

//...

}

}

}

 

//Find label control in button Click event

protected void getLabelObject(object sender, EventArgs e)

{

foreach (TableRow row in this.GridGroupingControl1.TopLevelTable.Rows)

{

GridRow gvr = row as GridRow;

if (gvr.DisplayElement.Kind == Syncfusion.Grouping.DisplayElementKind.Record)

{

Label cb = gvr.Cells[1].FindControl("Label2") as Label;

//...

}

}

}

 

For your convenience, we have prepared a simple sample to demonstrate this and the same can be downloaded from the below link,

 

Link: SampleProject.zip

 

Please let us know if you need any further assistance.

 

Regards,

 

Silambarasan I


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;