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

find control inside detailstable

3 Answers 172 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fred Mare
Top achievements
Rank 1
Fred Mare asked on 10 Dec 2010, 07:17 AM
Hi
I need to find a combobox inside a gridtableview inside the detailtables when the grid is in insert and edit mode. I am using a formtemplate. I have managed to get my controls inside the mastertableview using the following code. All of this needs to happen outside of the grid when I click a button.

if (hdLineItemRow.Value == string.Empty)
           {
cbo = (RadComboBox)radGrid.MasterTableView.GetInsertItem().FindControl("cbo");
           }
           else
           {
               int itemIdex = Convert.ToInt32(hdLineItemRow.Value);
               cbo = (RadComboBox)radGrid.MasterTableView.Items[itemIdex].EditFormItem.FindControl("cbo");
           }
  
Thank you
Fred

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 10 Dec 2010, 08:13 AM
Hello Fred,

Check out the following code snippet which shows how to get RadComboBox in insert/edit form of DetailTable from an external button click event.

C#:
protected void Button1_Click(object sender, EventArgs e)
 {
  foreach (GridDataItem item in RadGrid1.Items)
   {
    if (item.Expanded)
     {
      GridTableView tableView = (GridTableView)item.ChildItem.NestedTableViews[0]; // accessing Child Table view
      if (tableView.IsItemInserted)// if the child table view is in insert mode
       {
         GridEditFormInsertItem insertitem = (GridEditFormInsertItem)tableView.GetInsertItem();// accessing insert item
         RadComboBox combobox = (RadComboBox)insertitem.FindControl("cbo");
       }
      else
       {
         foreach (GridDataItem childitem in tableView.Items)
          {
           if (childitem.Edit)// checking if any of the item in Child table view is in edit mode
            {
              GridEditFormItem edititem = (GridEditFormItem)tableView.GetItems(GridItemType.EditFormItem)[childitem.ItemIndex];// accessing edit item
              RadComboBox combobox = (RadComboBox)edititem.FindControl("cbo");
            }
          }
        }
     }    
  }

Thanks,
Princy.
0
Fred Mare
Top achievements
Rank 1
answered on 11 Dec 2010, 02:45 PM
Thank you very much
0
SSirica
Top achievements
Rank 3
Iron
Iron
Iron
answered on 22 May 2014, 06:01 PM
OMG this is exactly what I was looking for.  Thank you!!!
Tags
Grid
Asked by
Fred Mare
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Fred Mare
Top achievements
Rank 1
SSirica
Top achievements
Rank 3
Iron
Iron
Iron
Share this question
or