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

Access nested Controls in Grirdview

1 Answer 38 Views
Input
This is a migrated thread and some comments may be shown as answers.
Bahram
Top achievements
Rank 2
Bahram asked on 30 May 2011, 01:56 PM
Hi everybody,
I tried to access a control ,for example,a textbox .There is one simple solution th this,
"

GridEditFormItem

 

 

editedItem = e.Item as GridEditFormItem;

 

 

 

 

TextBox txt1 = editedItem.FindControl("TextBox1") as TextBox;"

 


but when and in which event i shoud do this?for example In Telerik 2011 Demo(Input/RadInputManager/Integration with Grid) 
when  ItemCreated evnts fires,this part of code will be executed,but this events fires when an item is created ,just before that item has been initialized,so in this time the txt1.Text is Null and not the value the user has entered.
I want to change the insertCommand and need to pass the TextBox1.Text to the insertCommand ,
would anyone please tell me how ?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 May 2011, 07:31 AM
Hello Bahram,

ItemCreated is fired before the item is data-bound. Thus no data is still in the cells' text or input  controls. Data is available only in ItemDataBound. Check this documentation which explains more about this.

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
   {
      if (e.Item is GridEditableItem)
       {
        GridEditableItem item = (GridEditableItem)e.Item;
        TextBox txt1 = editedItem.FindControl("TextBox1") as TextBox;"
       }
   }

Thanks,
Princy.
Tags
Input
Asked by
Bahram
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Share this question
or