Saturday, March 24, 2012

ListView SelectedItem problem

I have a ListView object bound to a client-side DataTable. As I add a row to the table, I want the associated ListView item to become the selected item, as displayed using a different CSS.

I set up the listView with the selectedItemCssClass property, and as each item is clicked, it works fine. However, if I add a row to the table, the ListView re-binds correctly, but all items now appear as unselected.

This is all client-side behavior - no UpdatePanels or PageMethod calls.

1 - How do I force the record I added to become the selected item i the ListView?

2 - If I didn't want to do that, how do I ensure that the selected item remains selected when an item is added?

Much Thanks.

Although this might not work in the latest release, you should be able to set the selectedIndex or selectedItem in Javascript.

Yeah... obviously, since the Datatable went Preview some time ago. Closing this post.

No comments:

Post a Comment