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. Image for the cookie policy date

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

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

1 Reply

SI Silambarasan I Syncfusion Team 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


Loader.
Live Chat Icon For mobile
Up arrow icon