find control inside detailstable

4 posts, 1 answers
  1. Fred Mare
    Fred Mare avatar
    36 posts
    Member since:
    Dec 2009

    Posted 10 Dec 2010 Link to this post

    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
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 Dec 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Fred Mare
    Fred Mare avatar
    36 posts
    Member since:
    Dec 2009

    Posted 11 Dec 2010 Link to this post

    Thank you very much
  5. SSirica
    SSirica avatar
    50 posts
    Member since:
    Jan 2007

    Posted 22 May 2014 in reply to Princy Link to this post

    OMG this is exactly what I was looking for.  Thank you!!!
Back to Top