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

Accessing controls in radgrid EditTemplate edit mode

3 Answers 430 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 22 Feb 2012, 09:24 PM
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

3 Answers, 1 is accepted

Sort by
0
Elliott
Top achievements
Rank 2
answered on 23 Feb 2012, 05:41 PM
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
0
Princy
Top achievements
Rank 2
answered on 24 Feb 2012, 05:55 AM
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.
0
Amit
Top achievements
Rank 1
answered on 24 Feb 2012, 06:40 PM
That helped me. That's exactly what I want. Thanks for the quick reply.

Amit
Tags
Grid
Asked by
Amit
Top achievements
Rank 1
Answers by
Elliott
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Amit
Top achievements
Rank 1
Share this question
or