Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
935
How to Add CheckBox Template Field on ChildBand in Server Side Code?
posted

I am using Manual On Load Demand to Bind child grid in my WHDG.

This is My Code:

 protected void WebHierarchicalDataGrid1_RowIslandsPopulating(object sender, ContainerRowCancelEventArgs e)

        {

//Cancel the default automatic load on demand operation

            e.Cancel = true;

            // Get the data key

            int key = (int)e.Row.DataKey[0];

            _item.DetailId = key;

            var p = itemRead();

             // Create Container Grid

            ContainerGrid childGrid = new ContainerGrid();

            childGrid.InitializeRow += Child_InitializeeRow;

            e.Row.RowIslands.Add(childGrid);

            // Bind Grid

            childGrid.DataSource = p;

            childGrid.DataBind();

}

  private bool isChild;

   protected void Child_InitializeeRow(object sender, RowEventArgs e)

        {

            isChild = true;

            var gridRecord = (ContainerGridRecord)e.Row;

 

            if (gridRecord.Items.Count == 0)

                return;

 

            // Sets theItem Column

            var columnItemID = (BoundDataField)gridRecord.Items[0].Column;

            columnItemID.Width = 200;

            columnItemID.Header.Text = "ItemID";

           // ---------------------------------

                 In this Area i need to insert a check box which will be the last column

           //------------------------------------

}

 

I got this code from the other thread but i don't know how to use it yet:  

     public class ActionChildItemTemplate : ITemplate

        {

            #region ITemplate Member

            public void InstantiateIn(Control container)

            {

                CheckBox chk = new CheckBox();

                chk.ID = "chk";

                container.Controls.Add(chk);

            }

            #endregion

        }

 

After that  i need to loop the child band that is checked by the user and reference the key from parent row.

Thanks in Regards

 

 

 

 

  • 49378
    Verified Answer
    posted

    Hi NewbApps,

    It has been some time since your post, however in case you still need assistance I would be glad to help.

    You should be able to add a templated column to your container grid inside the RowIslandsPopulating handler using something similar to:

                TemplateDataField col = new TemplateDataField();
                col.ItemTemplate = new ActionChildItemTemplate();
                col.Key = "tempCol";

                if (child.Columns.FromKey("tempCol") == null)
                {
                    child.Columns.Add(col);
                }

    where child is the container grid element.

    Please feel free to contact me if you have any questions.

    Best Regards,

    Petar Ivanov
    Developer Support Engineer
    Infragistics, Inc.
    http://es.infragistics.com/support