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

Reference controls

2 Answers 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Roy Halvorsen
Top achievements
Rank 1
Roy Halvorsen asked on 11 Aug 2009, 11:44 AM
I have a RadGrid (radgrid1) with a FormTemplate. In the FormTemplate there is a TextBox (txtMyValue) and another RadGrid (radgrid2) which has set EditMode to InPlace. When radgrid2_updatecommand is firing, i want to update txtMyValue.Text. How can I reference txtMyValue from radgrid2?

var txtMyValue = radgrid1.MasterTableView.FindControl("txtMyValue") as TextBox -> is giving a null exception.

Anyone?

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 11 Aug 2009, 12:44 PM
Hello Roy,

You can try out the following code to access the textbox in the EditForm on updating a record in the grid inside the same form template:
c#:
protected void radgrid2_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == RadGrid.UpdateCommandName) 
        { 
            RadGrid grid = (RadGrid)source;            
            TextBox txtMyValue = (TextBox)grid.NamingContainer.FindControl("txtMyValue"); 
            
        } 
    } 

Thanks
Princy.
0
Roy Halvorsen
Top achievements
Rank 1
answered on 11 Aug 2009, 12:53 PM
Thanks a lot, Princy. It works :-)
Tags
Grid
Asked by
Roy Halvorsen
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Roy Halvorsen
Top achievements
Rank 1
Share this question
or