BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
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
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