I had the following, (which worked till I upgraded my Controls)
a method which returned via an arraylist any and all RadGrids found on a page ..i.e.
Logger.findRadGrids(Page.Controls);
which is as follows
public RadGrid findRadGrids(ControlCollection collection)
{
RadGrid result;
foreach (Control ctrl in collection)
{
if (ctrl.Controls.Count > 0)
{
result = findRadGrids(ctrl.Controls);
if (result != null)
{
RadGrids.Add(result);
}
}
else if (ctrl.GetType() == typeof(RadGrid))
{
RadGrids.Add(ctrl);
}
else if (ctrl.GetType() == typeof(Telerik.Web.UI.RadGrid))
{
RadGrids.Add(ctrl);
}
}
return null;
}
I then iterated thru this arraylist...getting the ItemCommand which I could then validate commandtypes against authorizations per user.
and log these.
//Originally...
foreach (RadGrid grid in Logger.RadGrids)
{
grid.ItemCommand += new GridCommandEventHandler(grid_ItemCommand);
}
//Now (mixed versions of RadCtls requiring .WebControls and .Web.UI )
for
(int i = 0; i < Logger.RadGrids.Count; ++i)
{
if (Logger.RadGrids[i].GetType() == typeof(Telerik.Web.UI.RadGrid))
{
Telerik.Web.UI.
RadGrid grid = (Telerik.Web.UI.RadGrid)Logger.RadGrids[i];
grid.ItemCommand +=
new Telerik.Web.UI.GridCommandEventHandler( grid_ItemCommand);
}
else
{
Telerik.WebControls.
RadGrid grid = (Telerik.WebControls.RadGrid)Logger.RadGrids[i];
grid.ItemCommand +=
new GridCommandEventHandler( grid_ItemCommand);
}
}
//Authorize or disallow actions on Grids
public void grid_ItemCommand(object source, GridCommandEventArgs e)
{
GridDataItem dataItem = new GridDataItem(((RadGrid)source).MasterTableView, 0, 0);
Hashtable htValues = new Hashtable();
switch (e.CommandName)
{
case RadGrid.UpdateCommandName:
{
if (!PagePrivilege.EditData)
{
disallowAction(
"Not allowed to Edit any Data");
e.Canceled =
true;
}
dataItem = ((
GridDataItem)((RadGrid)source).EditItems[0]);
goto extract;
}
case RadGrid.DeleteCommandName:
{
if (!PagePrivilege.DeleteData)
{
disallowAction(
"Not allowed to Delete any Data");
e.Canceled =
true;
}
dataItem = e.Item
as GridDataItem;
goto extract;
}
case RadGrid.PerformInsertCommandName:
{
if (!PagePrivilege.AddData)
{
disallowAction(
"Not allowed to insert any Data");
e.Canceled =
true;
}
((
RadGrid)source).MasterTableView.GetInsertItem().ExtractValues(htValues);
goto logg;
}
extract:
{
dataItem.ExtractValues(htValues);
goto logg;
}
logg:
{
this.Logger.logEvent(e.CommandName, htValues, 1);
break;
}
default:
{
break;
}
}
Now with the new versions of the controls, this generated the following error
Error 109 No overload for 'grid_ItemCommand' matches delegate 'Telerik.Web.UI.GridCommandEventHandler'
How do I go about fixing this please
TIA
Neal