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

How to refer a control in the Edit Form?

3 Answers 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jason M
Top achievements
Rank 2
Jason M asked on 16 Oct 2008, 07:05 PM
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.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Oct 2008, 04:59 AM
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
0
Jason M
Top achievements
Rank 2
answered on 17 Oct 2008, 02:19 PM
Thanks Shinu for your quick response!

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

Anything else I can try?

0
Iana Tsolova
Telerik team
answered on 17 Oct 2008, 02:48 PM
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.
Tags
Grid
Asked by
Jason M
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Jason M
Top achievements
Rank 2
Iana Tsolova
Telerik team
Share this question
or