Accessing controls in radgrid EditTemplate edit mode

4 posts, 0 answers
  1. Amit
    Amit avatar
    4 posts
    Member since:
    Jan 2012

    Posted 22 Feb 2012 Link to this post

    Is it possible to access other controls in EditTemplate when in edit mode beside the drop down list, because drop down list causes post back we can handle the event and access the other controls like you mentioned above. What I want to do is when user click the edit button on row item, I want to access a textbox which is in the EditTemplate and enable a required field validator on this text box. The field is required or not required depends on the drop down list in the form but since user is in edit mode he is not changing item on the drop down box.

    If there a way please also let me know the event in which I should access them.

    Please help me, I have spend so much time and still haven't found a solution yet.

    Thanks in advance,
    Amit

  2. Elliott
    Elliott avatar
    391 posts
    Member since:
    May 2010

    Posted 23 Feb 2012 Link to this post

    for starters, you'll either need to look at the ItemDataBound (if you need to look at the actual content of the control) event or the ItemCreated event (for the control without any data)

    in the ItemDataBound event, cast the e.Item to ??? not sure what the object is, it depends on a bunch of criteria
    then isolate the TableCell of the column you are interested in, then within that column tease out the control you want

    hope that helps

  3. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Feb 2012 Link to this post

    Hello,

    Try the following code.
    C#:

    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
     if (e.Item is GridEditableItem && e.Item.IsInEditMode)
     {  
      GridEditableItem item = (GridEditableItem)e.Item;
      TextBox textbox = (TextBox)item.FindControl("TextBox1");
     }
    }

    Thanks,
    Princy.

  4. Amit
    Amit avatar
    4 posts
    Member since:
    Jan 2012

    Posted 24 Feb 2012 Link to this post

    That helped me. That's exactly what I want. Thanks for the quick reply.

    Amit

Back to Top