I'm trying to use a switch statement based on the ID of the object (sender).
protected void SqlDataSource_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
int count = e.AffectedRows;
SqlDataSource sqlds = (SqlDataSource)sender;
switch (sqlds.ID)
{
case "sqldsPTY":
lblPTYCount.Text = "(" + count.ToString() + ")";
break;
case "sqldsINC":
lblINCCount.Text = "(" + count.ToString() + ")";
break;
...
}
}
but I get the exception:
System.InvalidCastException: Unable to cast object of type 'System.Web.UI.WebControls.SqlDataSourceView' to type 'System.Web.UI.WebControls.SqlDataSource'.
what am I doing wrong?