Reputation: 1713
So I have a grid view which gets data from a database. I want to be able to sort and page this table, as well as to remove single rows.
Now the Problem: I need to bind my data every time (also on postback), else my datasource will be null when trying to sort, but by doing so I will also get the wrong row each time I try to delete (or edit) a row.
Upvotes: 0
Views: 219
Reputation: 1713
The problem was that I thought that I had to bind the rows each time. All I had to do each time is to set the DataSouce and ONLY bind if (!IsPostBack). Then onSort i just bind again and it will be sorted. Also the delete-Function will then get the right row.
Upvotes: 1