Reputation: 3896
I have a listview and I need to perform certain actions based on OnSelectedIndexChanged which is fine.
But now I am getting an error about OnSelectedIndexChanging which is undefined. I have no need for that one. The strange thing is that the other day it wasn't giving that error while today it does. Do I need to define it even though I am not using it? I rather not since it does a refresh of the page if its just there with no code behind (meaning you have to press the Select link on the listview twice)
I am also getting " raised event ItemDeleting which wasn't handled." error when I click on the Delete link which I was not getting the other day.
What can cause the 2 issues above?
Upvotes: 0
Views: 1965
Reputation: 3637
If you bind listview to datasource at codebehind , you have to write some code in SelectedIndexChanging event.
So the code will be :
protected void ListView1_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
{
this.ListView1.SelectedIndex = e.NewSelectedIndex;
//bind listview again here !
}
onselectedindexchanging="ListView1_SelectedIndexChanging">
I Hope This will Solves your Problem.
Upvotes: 1
Reputation: 3896
The issue was that I was binding the data source manually and not at start up. The errors above have dissappeared once I initilize the data source along with the listview at start up.
Upvotes: 0
Reputation: 22323
I think you delete OnSelectedIndexChanging
from aspx.cs
page but you should not delete this event from your .aspx
page.So its try to invoke and rage error.Same case for ItemDeleting
.
Upvotes: 0