How to refer a control in the Edit Form?

4 posts, 0 answers
  1. Jason M
    Jason M avatar
    8 posts
    Member since:
    Jan 2007

    Posted 16 Oct 2008 Link to this post

    I use EditForm template in the RadGrid.
    In the 

    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)  
    {   
     
    }  
     
    I can use the following codes to refer a control in Insert Form: 
     
    GridEditableItem insertItem = e.Item.OwnerTableView.GetInsertItem();   
     
    ListBox ListBoxA = (ListBox)insertItem.FindControl("ListBox1");  
     
     

    How can I do the same thing for the Edit Form?

    "GridEditableItem insertItem = e.Item.OwnerTableView.GetInsertItem(); " doesn't work for the  Edit Form.  I got the error message "Insert item is available only when grid is in insert mode."

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

    Posted 16 Oct 2008 Link to this post

    Hi,

    Try accessing the controls in the editform in the edit mode as shown below.

    CS:
     protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
        { 
            if (e.CommandName == "Update") 
            { 
                GridEditableItem edititem = (GridEditableItem)e.Item; 
                ListBox txtbx = (ListBox)edititem.FindControl("ListBox1"); 
            } 
        } 


    Thanks
    Shinu
  3. Jason M
    Jason M avatar
    8 posts
    Member since:
    Jan 2007

    Posted 17 Oct 2008 Link to this post

    Thanks Shinu for your quick response!

    The solution you gave doesn't work. The txtbx returns value "null".

    Anything else I can try?

  4. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 17 Oct 2008 Link to this post

    Hello Jason,

    Please review the following help topics for further information on how to refer controls in FormTemplate:

    http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html
    http://www.telerik.com/help/aspnet-ajax/grdupdatingvaluesusercontrolformtemplate.html
    http://www.telerik.com/help/aspnet-ajax/grdinsertingvaluesusercontrolformtemplate.html

    Let us know if you need further directions.

    Regards,
    Iana
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top