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

RadGrid with Nested Panel - Find Control

2 Answers 217 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Julio
Top achievements
Rank 1
Julio asked on 27 Sep 2012, 04:02 AM
I have a radGrid control with a nested panel inside.  The panel contains various text boxes.  The only way that I have been able to find the text box within the nested panel is using a foreach loop.  I have not been able to only find the textbox within the selected row.  Below is the code i am using...

            foreach (GridNestedViewItem item1 in rgrdContacts.MasterTableView.GetItems(GridItemType.NestedView))
            {
                if (e.Item.Cells[3].Text == "False")
                {
                    string popupTitle = "Edit Contact";
                    LinkButton linkButton = (LinkButton)item1.FindControl("lbtnEditContact");
                    linkButton.Attributes.Add("onClick", BuildLightBox("../Pages/EditContact.aspx?IsDlg=0&ContactId=" + e.Item.Cells[2].Text, popupTitle, 960, 680));
                    linkButton.CssClass = "cwp-button";
                    linkButton.Visible = true;
                }
}

Thank you

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Sep 2012, 08:37 AM
Hi,

I suppose you want to access the TextBox inside the NestedViewTemplate on selecting the row. Here is the sample code.
C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
  foreach (GridDataItem item in RadGrid1.SelectedItems)
 {
   GridNestedViewItem nesteditem = (GridNestedViewItem)RadGrid1.MasterTableView.GetItems(GridItemType.NestedView)[0];
   TextBox txt = (TextBox)nesteditem.FindControl("TextBox1");
 }
}

Thanks,
Shinu.
0
Julio
Top achievements
Rank 1
answered on 27 Sep 2012, 11:57 AM
Thank you.  We were looking more for the onclick/expand command.  We ended up using the following code:

LinkButton linkButton = (LinkButton)((GridDataItem)e.Item).ChildItem.FindControl("NestedViewPanel").FindControl("lbtnEditContact");
Tags
General Discussions
Asked by
Julio
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Julio
Top achievements
Rank 1
Share this question
or