Transfer throws exception

7 posts, 0 answers
  1. Ed
    Ed avatar
    33 posts
    Member since:
    Sep 2012

    Posted 20 Aug 2013 Link to this post

    First, I am using version 2013.2.717.40.
    I set-up a very simple RadListBox transfer scenario:
         
    <telerik:RadListBox ID="StatusListBoxSource" runat="server" 
        AllowTransfer="True" DataSourceID="StatusDataSource" DataTextField="Description" 
        DataValueField="StatusId" TransferToID="StatusListBoxTarget" 
        Height="240px" Width="150px">
    </telerik:RadListBox>
    <telerik:RadListBox 
    ID="StatusListBoxTarget" runat="server" Height="240px" Width="150px"></telerik:RadListBox>

    There is a RadButton that is used to indicate that the user is ready to process the infiormation in the second box:
    <telerik:RadButton ID="DiagnoticStatusButton" runat="server" Text="Apply" AutoPostBack="True" 
        OnClick="DiagnoticStatusButton_Click">
    </telerik:RadButton>

    There is a label used to display the results of the processing:
    <asp:Label ID="DiagnosticStatusLabel" runat="server" Text=""></asp:Label>
    And an AjaxSetting to connect the button and the label:
       
    <telerik:AjaxSetting AjaxControlID="DiagnoticStatusButton">
        <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="DiagnosticStatusLabel" />
        </UpdatedControls>
    </telerik:AjaxSetting>
    The first time I transfer an item from the source box to the target box and click the button, everything works just fine. If I transfer another, without removing the first, and click the button, also works fine. However, when I transfer any more and click the button, I get an error that is caught in the Global.aspx.cs file with the Server class being something that does not contain a GetLastError method. This is before it gets into the button event handler in the code behind.

    Another issue, around which I am able to work is that, after transfering one item, a second click of the button reveals that there are 2 entries in the targetbox.items collection.

    Here is the code for the button click event:
    protected void DiagnoticStatusButton_Click ( object sender, EventArgs e )
        {
          ED.GenericResponse GR = new ED.GenericResponse ();
          List<String> IssueList = new List<String> ();
          List<Byte> StatusIdList = new List<Byte> ();
          var q = ( from si in this.StatusListBoxTarget.Items
                    select si.Value ).Distinct ();
          foreach ( String item in q )
          {
            StatusIdList.Add ( Byte.Parse ( item ) );
          }
          try
          {
            using ( EDG.GroupsDataContext ctx = new EDG.GroupsDataContext () )
            {
              Int32 EffectedRows = ctx.AddDevicesByCriteria ( this.GroupId, DateTime.Now.AddDays ( -1 ).Date, StatusIdList, IssueList );
              this.DiagnosticStatusLabel.Text = String.Format ( "{0} devices added", EffectedRows );
            }
          }
          catch ( Exception Ex )
          {
            Logger.ErrorException ( Ex.Message, Ex );
            this.DiagnosticStatusLabel.Text = "There was an error adding from diagnostic status";
          }
        }

    Unfortunately, there may be no way for you to reproduce this, but any suggestions would be accepted and appreciated.

    Thanks,

    Ed
  2. Ed
    Ed avatar
    33 posts
    Member since:
    Sep 2012

    Posted 21 Aug 2013 Link to this post

    Additional Information:

    I was previously experiencing an exception regarding an index being out of range. This stopped when the new exception was thrown without any changes.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ed
    Ed avatar
    33 posts
    Member since:
    Sep 2012

    Posted 21 Aug 2013 Link to this post

    Now we know the rest of the story:

    I was using a LinqDataSource to provide the data for the source list box. When I changed that to providing the data source as a list in the PageLoad event, the issue was resolved.
  5. Ed
    Ed avatar
    33 posts
    Member since:
    Sep 2012

    Posted 21 Aug 2013 Link to this post

    Well, I thought it was fixed. I still get an exception when I click the button a second time without transferring any items. This does not happen all of the time, but enough to make it problematic.
  6. Ed
    Ed avatar
    33 posts
    Member since:
    Sep 2012

    Posted 21 Aug 2013 Link to this post

    I finally was able to trap the exception:

    2013-08-21 10:08:00.9082 | Error | EnterpriseWeb.Global.Application_Error | Exception of type System.ArgumentOutOfRangeException thrown
    2013-08-21 10:08:00.9082 | Error | EnterpriseWeb.Global.Application_Error | Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index    at System.Collections.ArrayList.get_Item(Int32 index)
       at System.Web.UI.StateManagedCollection.System.Collections.IList.get_Item(Int32 index)
       at Telerik.Web.UI.ControlItemCollection.get_Item(Int32 index)
       at Telerik.Web.UI.ClientStateLogPlayer`1.Remove(ControlItemCollection items, Int32 index)
       at Telerik.Web.UI.ClientStateLogPlayer`1.Play(ClientStateLogEntry entry)
       at Telerik.Web.UI.ClientStateLogPlayer`1.Play(IEnumerable`1 clientStateLogEntry)
       at Telerik.Web.UI.RadListBox.LoadLogEntries(RadListBoxClientState clientState)
       at Telerik.Web.UI.RadListBox.LoadClientState(RadListBoxClientState clientState)
       at Telerik.Web.UI.RadListBox.LoadPostData(String postDataKey, NameValueCollection postCollection)
       at Telerik.Web.UI.RadDataBoundControl.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)
       at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  7. Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 23 Aug 2013 Link to this post

    Hello Ed,

    Please review the following forum topic, which explains in detail what's causing this issue, and how you can fix it:
    http://www.telerik.com/community/forums/aspnet-ajax/listbox/index-was-out-of-range-must-be-non-negative-and-less-than-the-size-of-the-collection-parameter-name-index.aspx

     

    Regards,
    Bozhidar
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  8. Ed
    Ed avatar
    33 posts
    Member since:
    Sep 2012

    Posted 23 Aug 2013 Link to this post

    Thank you, that worked.
    Sorry that I did not find that post in my search for a solution.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017