Reference controls

3 posts, 1 answers
  1. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 11 Aug 2009 Link to this post

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

    Posted 11 Aug 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 11 Aug 2009 Link to this post

    Thanks a lot, Princy. It works :-)
Back to Top