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

some questions about template textbox in radgrid hierachically

4 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
samaneh
Top achievements
Rank 1
samaneh asked on 02 Mar 2011, 08:11 AM
hi all
I have 3level Hierarchical radgrid in my page.
I  use a template column in it that have RadNumericTextBox and it has TextChanged method.

I have some questions and need your help please:

1)when user expand a node and type numbers in  RadNumericTextBox ,then collapse this,and then expand this node,text of this textbox was clear.
how can I avoid clearing datas(that users enterd)?

2)
In my RadNumericTextBox user enter number for grade.I want check this grade that wasn't greather than grade of it's parent.

In TextChanged Method,how can I reach the value of field "grade" of parent row of this textbox?

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 02 Mar 2011, 11:24 AM
Hello Samaneh,

In order to achieve your first requirement set the HierarchyLoadMode="Client" for MasterTableView.

And the following code snippet shows how to get the parent row in 'OnTextChanged' event of RadNumericTextBox.

C#:
protected void RadNumericTextBox_TextChanged(object sender, EventArgs e)
   {
       RadNumericTextBox textbox = (RadNumericTextBox)sender;
       GridDataItem item = (GridDataItem)textbox.NamingContainer;
       GridTableView tableview = (GridTableView)item.OwnerTableView;
       GridDataItem parentItem = (GridDataItem)tableview.ParentItem;//get parent row
       //can access the grade using parentItem
   }

-Shinu.
0
samaneh
Top achievements
Rank 1
answered on 02 Mar 2011, 12:04 PM
thank you shino
it works

and another question:

in text changed,how can I reach value of numericTextBox of other nodes that are it's brother(that have same parent)
0
Accepted
Princy
Top achievements
Rank 2
answered on 02 Mar 2011, 12:11 PM
Hello  Samaneh,

Try the following code to achieve this.

C#:
protected void RadNumericTextBox_TextChanged(object sender, EventArgs e)
    {
        RadNumericTextBox textbox = (RadNumericTextBox)sender;
         GridDataItem item = (GridDataItem)textbox.NamingContainer;
        GridTableView tableview = (GridTableView)item.OwnerTableView;
        foreach (GridDataItem coitem in tableview.Items)//loops through each child row
        {
            RadNumericTextBox cotextbox = (RadNumericTextBox)coitem.FindControl("RadNumericTextBox1"); //accessing TextBox using 'ID'
        }
    }

Thanks,
Princy.
0
samaneh
Top achievements
Rank 1
answered on 02 Mar 2011, 01:08 PM
thank you very much
Tags
Grid
Asked by
samaneh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
samaneh
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or