I’d wish to save some coding by being able to create a dynamic GetControl method. My ideas is something like this
private T GetControl<T>(ASPxGridView control, string element)
{
var returnedElement = (T)control.FindEditFormTemplateControl(element);
return returnedElement;
}
Which I call with
var myElement = GetControl<ASPxTextBox>(myGridView, "UserId");
But, this fails miserably:
Cannot convert type ‘System.Web.UI.Control’ to ‘T’
Any advices?
Try adding a generic constraint: