I have a ListView with SelectedItemTemplate. In the ItemTemplate I have a LinkButton with CommandName as "Select" that executes OnSelectedIndexChanging event.
The problem The problem is that when the Select button is clicked for the item that item doesn't appear in the SelectedItemTemplate, when the next Select button of next item is clicked, the previous selected item is displayed into SelectedItemTemplate.
OnSelectedIndexChanging="SelectionChanging"
The solution The solution of this problem is that we need to set the SelectedIndex of the ListView to the NewSelectedIndex and rebind the data
protected void SelectionChanging(Object sender, ListViewSelectEventArgs e)
{
ListView1.SelectedIndex = e.NewSelectedIndex;
this.RePopulateData(); // Re populate the data
}
I hope this helps.
Thanks
Regards,
Sheo Narayan
http://www.dotnetfunda.com