Hi Nabia,
When Parent-Children form of hierarchy Grid is defined, then the checkbox RowBtnTemplate can be specified in the form of checkbox template and binded for both parent and child Grids in QueryCellStyleInfo event. Please refer the code snippet to achieve this.
protected void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
{
//check for Parent Grid column to bind checkbox.
if (e.TableCellIdentity.Column.Name == "parentID")
{
CheckBox cb = new CheckBox();
cb.ID = "CheckBox1";
//Create a Template by implementing ITemplate interface and assign it to be the ItemTemplate for the column that needs to have a CheckBox.
TemplateClass mytemp = new TemplateClass(cb);
e.TableCellIdentity.Column.ItemTemplate = mytemp;
e.Handled = true;
}
if (e.TableCellIdentity.Column.Name == "childID")
{
CheckBox cb = new CheckBox();
cb.ID = "CheckBox2";
//check for Child Grid column to bind checkbox.
//Create a Template by implementing ITemplate interface and assign it to be the ItemTemplate for the column that needs to have a CheckBox.
TemplateClass mytemp = new TemplateClass(cb);
e.TableCellIdentity.Column.ItemTemplate = mytemp;
e.Handled = true;
}
}
}
public class TemplateClass : ITemplate
{
private Control m_ctrlChildControl = null;
public TemplateClass(Control ctrlChildControl)
{
m_ctrlChildControl = ctrlChildControl;
}
public void InstantiateIn(Control container)
{
container.Controls.Add(m_ctrlChildControl);
}
}
Please refer a sample below which illustrates the above.
http://files.syncfusion.com/support/GGC.Web/7.2.0.20/F81059_1/main.htmPlease let me know if you have any other concerns.
Thanks,
Rekha