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

Nested Item Reference

2 Answers 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
André Freitas
Top achievements
Rank 1
André Freitas asked on 05 May 2010, 07:50 PM
Im using a radgrid with paging, and handling the pageindexchanged, to save everything in the grid (a few checkboxes).

  protected void OnPageIndexChanged(object sender, GridPageChangedEventArgs e)
  {
   RadGrid radGrid = (RadGrid)sender;
   foreach (GridDataItem item in radGrid.Items)
   {
        CheckBox checkBox = (CheckBox)item.FindControl("chkList");
   }
  }

There's a nested item, with a textarea, in each item. How can I get a reference for the nested textarea inside each dataitem?

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 06 May 2010, 07:38 AM
Hello Andre,

I guess you are using textarea inside NestedViewTemplate. In order to get reference to the textarea related to each dataitem, you can iterate through the griditem collection and use the FindControl() method of NestedViewCell. Check out the following code:

C#:

 protected void RadGrid1_PageIndexChanged(object source, GridPageChangedEventArgs e) 
    { 
        RadGrid radGrid = (RadGrid)source; 
        foreach (GridDataItem item in radGrid.Items) 
         { 
           HtmlTextArea textArea = (HtmlTextArea)item.ChildItem.NestedViewCell.FindControl("Textarea1"); 
         } 
    } 

Regards,
Shinu.



0
André Freitas
Top achievements
Rank 1
answered on 06 May 2010, 01:07 PM
Thank you very much.
Tags
Grid
Asked by
André Freitas
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
André Freitas
Top achievements
Rank 1
Share this question
or