This is a migrated thread and some comments may be shown as answers.

RadListView SelectedIndexChanged event firing twice .

8 Answers 205 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Harendra
Top achievements
Rank 1
Harendra asked on 08 Oct 2013, 06:02 AM
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

8 Answers, 1 is accepted

Sort by
0
Deyan Enchev
Telerik team
answered on 10 Oct 2013, 02:32 PM

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.
0
Harendra
Top achievements
Rank 1
answered on 15 Oct 2013, 11:09 AM
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 ..!!
0
Deyan Enchev
Telerik team
answered on 18 Oct 2013, 08:31 AM
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.
0
Nidhi
Top achievements
Rank 1
answered on 30 Aug 2018, 07:05 AM

Hello Harendra,

"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."

Can you tell me how you solved this issue? What modification did you make to handle the issue of SelectionChanged event getting fired twice?

I'm facing some issue due to this, so need to fix it in my project.

Thanks in advance!

Regards

Nidhi Sood

0
Nidhi
Top achievements
Rank 1
answered on 30 Aug 2018, 07:11 AM

[quote]Harendra said: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 ..!!
[/quote]

Can you tell me how you fixed this problem of SelectionChanged event getting fired twice?

Thanks in advance.

0
Tsvetomir
Telerik team
answered on 03 Sep 2018, 02:00 PM
Hi Nidhi,

Generally, the SelectedIndexChanged event fires when you change the selected item. You can find out more on the event in the SelectedIndexChanged help article. 

Additionally, I have created a sample which has a ListView control and a label. When a change occurs, the SelectedIndexChanged event if fired and the label's content is populated.

Please download and run the sample to check the behavior on your side. It would be great if you could modify it to reproduce the issue you are facing and send it back to us for further investigation. 

Kind regards,
Tsvetomir
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Nidhi
Top achievements
Rank 1
answered on 20 Apr 2019, 07:45 AM

(Urgent)

Hello Everyone,

I'm facing a issue using RadListView.ItemSwipeContentTemplate.I'm using RadListView.ItemSwipeContentTemplate in Xamarin.Forms Xaml to provide swipe to delete functionality and it is working fine on iOS, but it is crashing on android with following exception:

Two different ViewHolders have the same stable ID. Stable IDs in your adapter MUST BE unique and SHOULD NOT change.
 ViewHolder 1:ViewHolder{2c32d85 position=1 id=897470586, oldPos=-1, pLpos:-1} 
 View Holder 2:ViewHolder{f138459 position=3 id=897470586, oldPos=-1, pLpos:-1} md5a5af569a83c1a3f5c3a8a63bd7d39860.RadExtendedListView{48b9b7c VFED..... ......ID 0,0-800,337}, adapter:com.telerik.widget.list.ListViewWrapperAdapter@272d2df, layout:android.support.v7.widget.LinearLayoutManager@deda80a, context:md5deafd3593ae57d3f60ebb5e1a22c84f4.MainActivity@454fb93

 

 at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualBooleanMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <fdf05f528e174febb3e55b587dbab368>:0 

  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <fdf05f528e174febb3e55b587dbab368>:0 
  at Android.Views.View.DispatchTouchEvent (Android.Views.MotionEvent e) [0x00031] in <d9e99b55e96444569d54148253f9c212>:0 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].DispatchTouchEvent (Android.Views.MotionEvent e) [0x00012] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:64 
  at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00011] in <d9e99b55e96444569d54148253f9c212>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.27(intptr,intptr,intptr)
  --- End of managed Java.Lang.IllegalStateException stack trace ---
java.lang.IllegalStateException: Two different ViewHolders have the same stable ID. Stable IDs in your adapter MUST BE unique and SHOULD NOT change.
 ViewHolder 1:ViewHolder{2c32d85 position=1 id=897470586, oldPos=-1, pLpos:-1} 
 View Holder 2:ViewHolder{f138459 position=3 id=897470586, oldPos=-1, pLpos:-1} md5a5af569a83c1a3f5c3a8a63bd7d39860.RadExtendedListView{48b9b7c VFED..... ......ID 0,0-800,337}, adapter:com.telerik.widget.list.ListViewWrapperAdapter@272d2df, layout:android.support.v7.widget.LinearLayoutManager@deda80a, context:md5deafd3593ae57d3f60ebb5e1a22c84f4.MainActivity@454fb93
at android.support.v7.widget.RecyclerView.handleMissingPreInfoForChangeError(RecyclerView.java:3852)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3777)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3447)
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1731)
at android.support.v7.widget.RecyclerView.scrollByInternal(RecyclerView.java:1779)
at android.support.v7.widget.RecyclerView.onTouchEvent(RecyclerView.java:2996)
at com.telerik.widget.list.RadListView.onTouchEvent(RadListView.java:518)
at android.view.View.dispatchTouchEvent(View.java:11776)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2962)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2643)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.dispatchTouchEvent(VisualElementRenderer_1.java:65)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.dispatchTouchEvent(VisualElementRenderer_1.java:65)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.dispatchTouchEvent(VisualElementRenderer_1.java:65)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.dispatchTouchEvent(VisualElementRenderer_1.java:65)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at md51558244f76c53b6aeda52c8a337f2c37.PlatformRenderer.n_dispatchTouchEvent(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.PlatformRenderer.dispatchTouchEvent(PlatformRenderer.java:55)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:448)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1829)
at android.app.Activity.dispatchTouchEvent(Activity.java:3307)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:410)
at android.view.View.dispatchPointerEvent(View.java:12015)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4795)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4609)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4200)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4166)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4293)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4174)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4350)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4200)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4166)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4174)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6661)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6635)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6596)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6764)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:186)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:177)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:6735)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6787)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:652)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Can anyone look into this issue and provide me some guidance, because I couldn't find anything regarding this issue yet and it is really very urgent.

Thanks !!

0
Yana
Telerik team
answered on 24 Apr 2019, 11:50 AM
Hi Nidhi,

Thank you for sending the stacktrace. 

We've actually been reported such an issue with RadListView once, however, we didn't manage to reproduce it locally. In this case, could you please send us more details regarding your setup? Also could you send us a sample project where the issue could be reproduced or a xaml file where the RadListView control is defined? 
It would also be helpful if you specify the exact Xamarin.Forms version that you're using.

Thanks in advance.

Regards,
Yana
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ListView
Asked by
Harendra
Top achievements
Rank 1
Answers by
Deyan Enchev
Telerik team
Harendra
Top achievements
Rank 1
Nidhi
Top achievements
Rank 1
Tsvetomir
Telerik team
Yana
Telerik team
Share this question
or