RadListView SelectedIndexChanged event firing twice .

4 posts, 0 answers
  1. Harendra
    Harendra  avatar
    9 posts
    Member since:
    Jun 2013

    Posted 08 Oct 2013 Link to this post

    Hi everyone,

    I have a RadListView that is bind to Db. I have to show details of the items in listview when user clicks on the each item . But i am facing issue when its SelectedIndexChanged event is firing. When user clicks on the item for the first time, the detailed data shown is correct but as soon as a second item is clicked , it shows exception :

    ArgumentOutOfRangeException :
    Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index

    Exception is thrown when : 

    ItemID = ItemListView.SelectedValue.ToString();

    Showing data as similar to a demo - http://demos.telerik.com/aspnet-ajax/salesdashboard/
    Employee ListView  -> clicking showing - > sales data

    Also i found that the selectedindexchanged event is firing twice in some cases. Cannot predict such cases but want to know the reason why it is firing twice when user clicks only once.

    please advice
  2. Deyan Enchev
    Admin
    Deyan Enchev avatar
    60 posts

    Posted 10 Oct 2013 Link to this post

    Hello Harendra,

    Have in mind that SelectedIndexChanged occurs when the selection changes between posts to the server. In order this control to persist the values make sure that view state is enabled.

    The error you are getting is common and it is hard to determine what is causing it. We would appreciate if you provide us with a small runnable project that exhibits the problem.

    Regards,
    Deyan Enchev
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Harendra
    Harendra  avatar
    9 posts
    Member since:
    Jun 2013

    Posted 15 Oct 2013 Link to this post

    Hi Deyan,

    I just solved the triggering of selectedindex changed event of listview that was happening twice. It was just a modification in code. But yes somewhere if i still come across such kind of issues, i will mail a sample project for that in the ticket.

    I have an another similar question regarding listview in regard to this thread only. I have used many controls like drop down , gridview etc but didn't find anything like to rebind the control whenever its selectedindexchanged event is fired?

    But today when i was working with the Listview of which i was firing its SelectedIndexChanged event on item selection, what i noticed that the event runs successfully for the first time and details of the item selected is shown but as soon as some other item is selected, the event throws an error on the code where it accepts the item value - as shown below

    ArgumentOutOfRangeException :
    Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index

    Exception is thrown when : 

    ItemID = ItemListView.SelectedValue.ToString();


     I Though of rebinding it in the event itself and the problem went away.
    I am still confused that why i should rebind listview in the SelectedIndexChanged event.

    Thanks for reading and any useful info will be appreciated ..!!
  5. Deyan Enchev
    Admin
    Deyan Enchev avatar
    60 posts

    Posted 18 Oct 2013 Link to this post

    Hi,

    Could you elaborate more on your scenario and Data Binding you are using? Without having your markup and the code behind it is hard to determine what the root cause of the issue is.

    In case you would like to know more about RadListView data binding it is explained in our help topic here.

    Regards,
    Deyan Enchev
    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.
Back to Top