filling text box by selected node of the rad tree

4 posts, 0 answers
  1. Ramakrishna
    Ramakrishna avatar
    16 posts
    Member since:
    Aug 2008

    Posted 28 Oct 2010 Link to this post


    HI  ALL

    I have a  text box in  edit item template in a rad grid

    during the edit mode i fill this  text box with the selected node of the  RAD tree .

     not able to find the text box during the edit mode whereas during insert its working fine.



        protected void RadTreeView1_NodeClick(object sender, RadTreeNodeEventArgs e)
        {

            RadTreeView TreeNode = (RadTreeView)TreeControle.FindControl("RadTreeView1");
                -------------------------THIS PART IS WORKING FINE--------------------------------------
                  if (rdUserlist.MasterTableView.IsItemInserted == true)
                {

                    TextBox txtCb1 = (TextBox)rdUserlist.MasterTableView.GetInsertItem().FindControl("txtCb");
                    txtCb1.Text = SLName;               

                }
                else  
                {

                    --------------------NOT ABLE TO FIND THE TEXT BOX  DURING EDIT ------------------------------------------------
                    -----------------OBJECT REFRENCE ERROR -----------------------------------------------------

                    TextBox txtCb1 = (TextBox)rdUserlist.MasterTableView.EditItem.FindControl("txtCb");
                    txtCb1.Text = SLName;  
                   
                }
                TreeNode.CollapseAllNodes();
                TreeNode.ClearSelectedNodes();
                      }
        
        }

     


    Thanks


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 28 Oct 2010 Link to this post

    Hi Ramakrishna,


    Here is the code to access the control placed in editform.

    C#:
    GridEditableItem editItem = (GridEditableItem)RadGrid1.EditItems[0];
    (editItem.FindControl("lblRateE") as TextBox).Text = SLName;




    -Shinu.
  3. Ramakrishna
    Ramakrishna avatar
    16 posts
    Member since:
    Aug 2008

    Posted 28 Oct 2010 Link to this post

    Hi ,

    thanks for your reply.

    But i am getting object refrence error on using the provided sol.

  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 28 Oct 2010 Link to this post

    Hello,


    If you are using EditMode as EditForms, then try the following code.

    Code:
    GridEditFormItem editItem = (GridEditFormItem)RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem)[Convert.ToInt32(RadGrid1.EditIndexes[0])];
    (editItem.FindControl("txtCb") as TextBox).Text = "changed";

    Note: Also make sure that you passed correct ID of the control in FindControl() method (In my previous reply, it is different than yours).


    -Shinu.
Back to Top