This code is a representation of my logic. Obviously it does not work. Please advise on how to make it work.
switch (ObjectToControl.GetType().ToString())
{
case "DataList":
DataList Controled = (DataList)ObjectToControl;
break;
case "DetailsView":
DetailsView Controled = (DetailsView)ObjectToControl;
break;
case "FormView":
FormView Controled = (FormView)ObjectToControl;
break;
case "ListView":
ListView Controled = (ListView)ObjectToControl;
break;
default:
GridView Controled = (GridView)ObjectToControl;
break;
}