Я использую смесь ListView + DataPager + ObjectDataSource.
В реализация моего SelectMethod объекта ObjectDataSource I ' я хочу получить доступ к глобальной переменной, установленной в событии PageLoad () (метод вернет только правильное количество элементов на странице). Хотя переменная инициализируется в PageLoad (), в SelectMethod она кажется нулевой. Как я могу это изменить?
<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
}