I have an object datasource that looks like this:
<asp:ObjectDataSource ID="obdsList" runat="server"
EnablePaging="True" SelectCountMethod="GetCountByID" SortParameterName="sortExpression"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetByID"
TypeName="Services.Users"
onselected="obdsList_Selected">
<SelectParameters>
<asp:QueryStringParameter Name="ID" QueryStringField="ID"
Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
And a onselected event like this:
protected void obdsList_Selected(object sender, ObjectDataSourceStatusEventArgs e) {
}
However, the event method is being called twice.. once with my returned list, and once with the returned Int32 count. If I want to cast e.ReturnValue
to the return List how do I differentiate between the count and select methods? I can do a e.ReturnValue.GetType().ToString()
but that seems like a hack.
I'm doing this...
protected void obdsList_Selected(object sender, ObjectDataSourceStatusEventArgs e)
{
if (e.ReturnValue != null)
{
if (e.ReturnValue.GetType() == typeof(int))
{
//e.ReturnValue is the SelectCountMethod value
}
}
}