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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to create ItemTemplates programatically in GridgroupingControl?

Platform: ASP.NET Web Forms (Classic) |
Control: GridGroupingControl


Please refer the below steps involved to create ItemTemplates programatically:

  • In QueryCellStyleInfo event an instance for the TemplateClass of that particular item should be created and assigned it to the EditItemTemplate of that column.


protected void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)


//Look for the RecordField and AlternateField Cell.

if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)


//Look for the Column Name "Column2" in the GridGroupingControl when it get rendered

if (e.TableCellIdentity.Column.Name == "Column2")


Syncfusion.Web.UI.WebControls.Shared.DropDownCalendarControl dropdown = new DropDownCalendarControl();

dropdown.ClientObjectId = "ddcal";


dropdown.Format = DateTimeFormatType.CustomString;

dropdown.Attributes.Add("onclick", "fun1(this);");


dropdown.AutoPostBack = true;

//Here we adding the DropDownListBox programatically using ITemplate Interface

TemplateClass mytemp = new TemplateClass(dropdown);

e.TableCellIdentity.Column.EditItemTemplate = mytemp;





Protected Sub GridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)

'Look for the RecordField and AlternateField Cell.

If e.TableCellIdentity.TableCellType = GridTableCellType.RecordFieldCell OrElse e.TableCellIdentity.TableCellType = GridTableCellType.AlternateRecordFieldCell Then

'Look for the Column Name "Column2" in the GridGroupingControl when it get rendered

If e.TableCellIdentity.Column.Name = "Column2" Then

Dim dropdown As Syncfusion.Web.UI.WebControls.Shared.DropDownCalendarControl = New DropDownCalendarControl()

dropdown.ClientObjectId = "ddcal"


dropdown.Format = DateTimeFormatType.CustomString

dropdown.Attributes.Add("onclick", "fun1(this);")


dropdown.AutoPostBack = True

'Here we adding the DropDownListBox programatically using ITemplate Interface

Dim mytemp As TemplateClass = New TemplateClass(dropdown)

e.TableCellIdentity.Column.EditItemTemplate = mytemp

End If

End If

End Sub

  • Define the TemplateClass which is inherited from ITemplate. Please refer the below code snippet which illustrates this:


public class TemplateClass : ITemplate


private Control m_ctrlChildControl = null;

public TemplateClass(Control ctrlChildControl)


m_ctrlChildControl = ctrlChildControl;


public void InstantiateIn(Control container)






Public Class TemplateClass : Implements ITemplate

Private m_ctrlChildControl As Control = Nothing

Public Sub New(ByVal ctrlChildControl As Control)

m_ctrlChildControl = ctrlChildControl

End Sub

Public Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn


End Sub

End Class



You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

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

Live Chat Icon For mobile