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 header template

Thread ID:

Created:

Updated:

Platform:

Replies:

117135 Aug 20,2014 06:44 AM UTC Aug 31,2014 05:42 PM UTC ASP.NET Web Forms (Classic) 3
loading
Tags: GridGroupingControl
Narry
Asked On August 20, 2014 06:44 AM UTC

Please help me

Silambarasan I [Syncfusion]
Replied On August 26, 2014 05:48 AM UTC

Hi Narry,

 

Thank you for using Syncfusion Products.

 

We are glad to let know that your requirement “How to find label control in grid grouping control of header template” can be achieved by using on 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">

<HeaderTemplate>

<asp:Label ID="Label1" runat="server" Text="OrderID(Label)" Font-Bold="true"></asp:Label>

</HeaderTemplate>

</syncfusion:GridColumnDescriptor>

//...

</Columns>

</TableDescriptor>

</Syncfusion:GridGroupingControl>

 

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

[ASPX.CS]

 

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.ColumnHeader)

{

 

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

 

ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('"+cb.Text+"');", true);

}

}

}

 

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


mohsin
Replied On August 28, 2014 10:11 AM UTC

how to find lable control in grid grouping control of header template in pageload


Silambarasan I [Syncfusion]
Replied On August 31, 2014 05:42 PM UTC

Hi Mohsin,

 

Thanks for your update.

 

We would like to let you know that your requirement “To find lable control in grid grouping control of header template in pageload” can be achieved by using prerender event.  Please refer the below code snippets.

 

CODE SNIPPET:

 

[ASPX]

 

<syncfusion:GridColumnDescriptor MappingName="OrderID">

<HeaderTemplate>

<asp:Label ID="Label1" runat="server" Text="Label1" Font-Bold="true"></asp:Label>

</HeaderTemplate>

</syncfusion:GridColumnDescriptor>

//...

</Columns>

</TableDescriptor>

</Syncfusion:GridGroupingControl>

 

[ASPX.CS]

 

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

//Bind data to GridGroupingControl.

this.GridGroupingControl1.DataSource= GetData();

this.GridGroupingControl1.DataBind();

 

this.GridGroupingControl1.PreRender += GridGroupingControl1_PreRender;

 

}

}

 

void GridGroupingControl1_PreRender(object sender, EventArgs e)

{

foreach (TableRow row in (((GridGroupingControl)(sender)).TopLevelTable).Rows)

{

GridRow gvr = row as GridRow;

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

{

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

//...

cb.Text = "OrderID";

}

}

}

 

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

;