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

filling text box by selected node of the rad tree

3 Answers 58 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ramakrishna
Top achievements
Rank 1
Ramakrishna asked on 28 Oct 2010, 12:00 PM

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


3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Oct 2010, 12:55 PM
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.
0
Ramakrishna
Top achievements
Rank 1
answered on 28 Oct 2010, 01:19 PM
Hi ,

thanks for your reply.

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

0
Shinu
Top achievements
Rank 2
answered on 28 Oct 2010, 01:44 PM
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.
Tags
TreeView
Asked by
Ramakrishna
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ramakrishna
Top achievements
Rank 1
Share this question
or