Access nested Controls in Grirdview

2 posts, 0 answers
  1. Bahram
    Bahram avatar
    15 posts
    Member since:
    Mar 2011

    Posted 30 May 2011 Link to this post

    Hi everybody,
    I tried to access a control ,for example,a textbox .There is one simple solution th this,




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

    Posted 31 May 2011 Link to this post

    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.

    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;"

Back to Top