2012-01-30 17 views
3

と「容量が現在のサイズよりも少なかった」:エラー:私はこのコードに従ってDataPagerとASP.NET ListViewコントロールを持っているASP.NET DataPagerコントロール

 <asp:ListView ID="TicketsPerPersonListView" runat="server" DataSourceID="ObjectDataSource1"> 
     <EmptyDataTemplate> 
      -- No Records Found -- 
     </EmptyDataTemplate> 
     <ItemTemplate> 
      <tr style="display: table-row;"> 
       <td> 
        <a href="viewticket.aspx?id=<%#Eval("ticket_id")%>">#<%# Eval("TicketID")%>- 
         <%# Eval("ShortDesc")%></a> 
       </td> 
       <td> 
        <%# Eval("StatusName")%> 
       </td> 
       <td style="text-align: right; padding-right: 60px;"> 
        <%# Eval("StatusDescription")%> 
       </td> 
       <td style="text-align: right; padding-right: 60px;"> 
        <%# Eval("TimeLastAction")%> 
       </td> 
      </tr> 
     </ItemTemplate> 
     <LayoutTemplate> 
      <table> 
       <thead> 
        <tr> 
         <th> 
          Title 
         </th> 
         <th style="text-align: right; padding-right: 60px;"> 
          Current Status 
         </th> 
         <th style="text-align: right; padding-right: 60px;"> 
          Latest Action 
         </th> 
         <th style="text-align: right; padding-right: 60px;"> 
          Last Viewed 
         </th> 
        </tr> 
       </thead> 
       <tfoot> 
        <tr> 
         <td colspan="5"> 
          <div class="pagination"> 
           <asp:DataPager ID="TicketsPerPersonDataPager" runat="server" PagedControlID="TicketsPerPersonListView" 
            PageSize="10"> 
            <Fields> 
             <asp:NextPreviousPagerField FirstPageText="&lt;&lt;" ShowFirstPageButton="True" ShowNextPageButton="False" 
              ShowPreviousPageButton="False" /> 
             <asp:NumericPagerField CurrentPageLabelCssClass="graybutton pagelink active" NumericButtonCssClass="graybutton pagelink" /> 
             <asp:NextPreviousPagerField LastPageText="&gt;&gt;" ShowLastPageButton="True" ShowNextPageButton="False" 
              ShowPreviousPageButton="False" /> 
            </Fields> 
           </asp:DataPager> 
          </div> 
         </td> 
        </tr> 
       </tfoot> 
       <tbody> 
        <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder> 
        <tr style="display: table-row;"> 
        </tr> 
       </tbody> 
      </table> 
     </LayoutTemplate> 
    </asp:ListView> 
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" EnablePaging="True" SelectMethod="FindByUserID" 
     TypeName="Xyratex.XCS.Services.TicketService" StartRowIndexParameterName="startRowIndex" 
     MaximumRowsParameterName="maximumRows" SelectCountMethod="CountByUserID"> 
     <SelectParameters> 
      <asp:Parameter Name="userID" DbType="Int64" DefaultValue="79" /> 
      <asp:ControlParameter Name="custID" ControlID="DDCaller" ConvertEmptyStringToNull="True" 
       DefaultValue="" /> 
      <asp:ControlParameter Name="company" ControlID="DDCompany" ConvertEmptyStringToNull="True" 
       DefaultValue="" /> 
      <asp:ControlParameter Name="owner" ControlID="DDOwner" ConvertEmptyStringToNull="True" 
       DefaultValue="" /> 
      <asp:ControlParameter Name="action" ControlID="DDAction" ConvertEmptyStringToNull="True" 
       DefaultValue="" /> 
      <asp:ControlParameter Name="status" ControlID="DDCurrentStatus" ConvertEmptyStringToNull="True" 
       DefaultValue="" /> 
     </SelectParameters> 
    </asp:ObjectDataSource> 

VB.NETのコードは、そのObjectDataSourceにデータを提供します。

''' <summary> 
''' Finds all the <see cref="Xyratex.XCS.Model.Tickets.Ticket" /> objects belonging to the specified user ID 
''' </summary> 
''' <param name="userID">The id of the user to find tickets for</param> 
''' <param name="startRowIndex">The starting index of the portion of the recordset</param> 
''' <param name="maximumRows">The maximum amount of rows to return</param> 
''' <param name="custID">The id of the customer to find tickets for</param> 
''' <param name="company">The company name to find tickets for</param> 
''' <param name="owner">The owner to find tickets for</param> 
''' <param name="action">The action to find tickets for</param> 
''' <param name="status">The status of tickets to find.</param> 
''' <returns>A <see cref="System.Collections.Generic.IList(Of Xyratex.XCS.Model.Tickets.Ticket)" /> object</returns> 
''' <remarks>XY01\rpenfold 30 January 2012</remarks> 
Public Function FindByUserID(ByVal userID As Long, 
          ByVal startRowIndex As Long, 
          ByVal maximumRows As Long, 
          ByVal custID As Long?, 
          ByVal company As String, 
          ByVal owner As Integer?, 
          ByVal action As Char?, 
          ByVal status As Long?) As List(Of LightWeightTicket) Implements ITicketRepository.FindByUserID 
    'Start a new session and run the query 
    Using session As NHibernate.ISession = SessionFactory.GetNewSession() 
     Dim query As NHibernate.IQuery = session.GetNamedQuery("Select_AllTickets_ByUserID_RyanTest") 
     query.SetInt64("user_id", userID) 
     Select Case custID.HasValue 
      Case True 
       query.SetInt64("cust_id", custID.Value) 
      Case False 
       query.SetString("cust_id", Nothing) 'SetString makes it NULL 
     End Select 
     Select Case String.IsNullOrWhiteSpace(company) 
      Case True 
       query.SetString("company", Nothing) 
      Case False 
       query.SetString("company", company) 'SetString makes it NULL 
     End Select 
     Select Case owner.HasValue 
      Case True 
       query.SetInt32("owner", owner.Value) 
      Case False 
       query.SetString("owner", Nothing) 'SetString makes it NULL 
     End Select 
     Select Case action.HasValue 
      Case True 
       query.SetCharacter("action", action.Value) 
      Case False 
       query.SetString("action", Nothing) 'SetString makes it NULL 
     End Select 
     Select Case status.HasValue 
      Case True 
       query.SetInt64("status", status.Value) 
      Case False 
       query.SetString("status", Nothing) 'SetString makes it NULL 
     End Select 
     query.SetInt64("startRowIndex", startRowIndex) 
     query.SetInt64("maximumRows", maximumRows) 
     Return New List(Of LightWeightTicket)(query.List(Of LightWeightTicket)()) 
    End Using 
End Function 

ページを読み込むと、「容量が現在のサイズよりも小さい」というエラーが表示されます。スタックトレースは、このようごとある:

[ArgumentOutOfRangeException: capacity was less than the current size. 

パラメータ名:値] System.Collections.ArrayList.set_Capacity(のInt32値)9360651 System.Web.UI.WebControls.ListView.CreateChildControls(IEnumerableをデータソース、ブールデータバインド)+712 System.Web.UI.WebControls.ListView.PerformDataBinding(IEnumerableデータ)+35 System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerableデータ)+128 System.Web.UI.DataSourceView.Select (DataSourceSelectArguments引数、DataSourceViewSelectCallbackコールバック)+33 System.Web.UI.WebControls.DataBoundControl.PerformSelect()+143()+74 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()+66 System System.Web.UI.Control.EnsureChildControls()+ .PreRenderRecursiveInternal()175 System.Web.UI.Control.PreRenderRecursiveInternal()2496

がい175 System.Web.UI.Page.ProcessRequestMain(ブールincludeStagesBeforeAsyncPoint、ブールのincludeStagesAfterAsyncPoint)あなたはこれについて何をすべきかを知っていますか?事前に

おかげで、

ライアン

+0

質問とは関係ありませんが、なぜSelect Caseを使用するのですか?これは目の上でより簡単で簡単です: 'もしオーナーなら、値段...そうでなければ...終わりIf' –

+0

私は好きな場合を選びます:o) –

答えて

3

私はそれを解決!

CountメソッドがSystem.Int64を返していました。これがSystem.Int32に修正されたとき、それは機能しました!

+0

ありがとう!私はちょうど同じ問題を経験しました!それは私を助けました。 – Sergey

関連する問題