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

how to findcontrol in the grid from a custom method

2 Answers 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
bo
Top achievements
Rank 1
bo asked on 19 Feb 2009, 03:06 PM
ok...here's my deal...i've got a grid that in edit mode uses a Template...i do something while in edit mode that causes an ajaxrequest which fires a custom method...

while executing that custom method i can do a GridEditableItem edititem = (GridEditableItem)this.rgCustomDiagnosis.EditItems[0];
and have a tie to the current editable record...

but i can't for the life of me figure out how to find a textbox in the edit template...

edititem.findcontrol("txtCoreCode")  just returns a null

help please

thanks

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Feb 2009, 04:40 AM
  
0
Shinu
Top achievements
Rank 2
answered on 20 Feb 2009, 05:14 AM
Hi,

Try the following code snippet to access a control when the Grid is in editmode.

CS:
  //code to access controls from edit form when the EditMode is EditForms 
        foreach (GridEditFormItem editFormItem in rgCustomDiagnosis.MasterTableView.GetItems(GridItemType.EditFormItem)) 
        { 
            if (editFormItem.IsInEditMode) 
            { 
                TextBox txtbx = (TextBox)editFormItem.FindControl("txtCoreCode"); 
 
            } 
        } 
 
        //code to access controls from edit form when the EditMode is InPlace 
        foreach (GridEditableItem editItem in rgCustomDiagnosis.MasterTableView.GetItems(GridItemType.EditItem)) 
        { 
            if (editItem.IsInEditMode) 
            { 
                TextBox txtbx = (TextBox)editItem.FindControl("txtCoreCode"); 
            } 
        } 


Thanks
Shinu
Tags
Grid
Asked by
bo
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or