I'm using ListView + DataPager + ObjectDataSource mix.
In the implementation of my SelectMethod of an ObjectDataSource I'd like to access a global variable set in the PageLoad() event (the method will return just the proper number of items per page). Although the variable is initialized in PageLoad() it appears to be null in SelectMethod. How can I change that?
<asp:ObjectDataSource ID="ItemsObjectDataSource" runat="server" EnablePaging="True"
SelectMethod="WrapSearchResults" SelectCountMethod="CountSearchResults"
TypeName="Catalogue">
<SelectParameters>
<asp:QueryStringParameter Name="startRowIndex" QueryStringField="page" Type="Int32" DefaultValue="0" />
<asp:Parameter Name="maximumRows" Type="Int32" DefaultValue="10" />
</SelectParameters>
</asp:ObjectDataSource>
SearchOption search;
protected void Page_Load(object sender, EventArgs e)
{
search = new SearchOption(SessionParameters.Get(Session).User);
}
public IEnumerable<ResultWrapper> WrapSearchResults(int startRowIndex, int maximumRows)
{
search.Limit = maximumRows; <-- null pointer exception
}