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
20
Read rows from child band
posted

I am using the below code to read records from child band. When I collapse the parent band, the below code is not returning the rows within  parent band. I also have pagination in the child band. This code returns the record only from the first page of child band and not iterating the rows in remaining page. 

Requirement is to iterate all child records within grid spanning across all rows and add all the child rows to data table which are selected using the checkbox. 

 foreach (ContainerGridRecord ChildRecords in this.WebHierarchicalDataGrid1.GridView.Rows)
        {            
            foreach (ContainerGrid ChildRecord in ChildRecords.RowIslands)
            {
                for (int Count = 0; Count < ChildRecord.Rows.Count; Count++)
                {
                    GridRecordItem item = ChildRecord.Rows[Count].Items[0];
                    if (item.Value.ToString() == "True")
                    {
                        string ClaimNumber = ChildRecord.Rows[Count].Items[1].Value.ToString();
                        DataRow filteredRow= ((DataRowView)((DataSetNode)(ChildRecord.Rows[Count].DataItem)).Item).Row;
                        childData.Rows.Add(filteredRow.ItemArray);
                    }
                }                             
            }            
        }
Thanks
Parents
No Data
Reply
  • 16310
    Offline posted

    If parent row is collapsed, then you can iterate through all child records to match the rows that would go under the given parent row:

            //Iterage through parent grid.
            foreach (GridRecord row in this.WebHierarchicalDataGrid1.GridView.Rows)
            {  // Here we take all child records if the parent row is selected and collapsed
                    if (((ContainerGridRecord)row).IsEmptyParent)
                    {
                        var foundRows = ChildDataTable.AsEnumerable()
                            .Where(x => x.ItemArray[1].ToString().Contains(row.DataKey[0].ToString())).CopyToDataTable().Rows;         
                    }
                }
            }

Children
No Data