This is a migrated thread and some comments may be shown as answers.

Enable to find the ChildItem at Item Created event of Child grid after pagination or column sorting of parent grid

2 Answers 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MadhuSudhan
Top achievements
Rank 1
MadhuSudhan asked on 19 Apr 2011, 03:41 PM
In the following code, grdInProcesDetails is a child grid of  "grdInProces" parent grid, After doing the pagination of "grdInProces" grid,
in grdInProcesDetails_ItemCreated - parentItem.ChildItem is getting null, by which i am unable to find the childItem controls to add some attributes .... How do i find the child item controls  here in this case.
  protected void grdInProcesDetails_ItemCreated(object sender, GridItemEventArgs e)
        {
             if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                GridDataItem parentItem = ((sender as RadGrid).NamingContainer as GridNestedViewItem).ParentItem as GridDataItem;
                  if (parentItem != null && parentItem.ChildItem !=null)
                {
                    string _employeeId = parentItem.GetDataKeyValue("Employee").ToString();
                    Label lblIPName = parentItem.FindControl("lblIPName") as Label;
                    Label lblReview = parentItem.ChildItem.FindControl("lblReview") as Label;
                    CheckBox chkIPReviewed = parentItem.ChildItem.FindControl("chkInProcessReviewed") as CheckBox;
               }
          }
     }
Parent grid is getting rebind as well as child grid also getting rebinding when done pagination but syill iam getting null value.

Please give a advise as soon as possible

2 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 22 Apr 2011, 03:03 PM
Hi,

In the ItemCreated event you cannot be sure if another given item is already created at the time the current one is. Therefore, I would advise you to intercept the ItemCommand event when paging and trying to do the changes there.
If the changes do not require a rebind on the grid, you can also traverse the grid items on grid PreRender and do the needed:
Traversing detail tables/items in Telerik RadGrid

Best wishes,
Tsvetina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
MadhuSudhan
Top achievements
Rank 1
answered on 25 Apr 2011, 02:56 PM
Thank you very much i got my clarity....... It worked and gave a scope to continue further.
Tags
Grid
Asked by
MadhuSudhan
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
MadhuSudhan
Top achievements
Rank 1
Share this question
or