0
votes

I have a SPGridview with data in and works fine. I've enabled Allow sorting.

I Click on the heading and the functionality works as expected but for some reason the SPGridView then renders 2 times(side by side) For every click on a sortable header another SPGridView is added.

The way i have this working currently is in a Visual web part so the SPGridView is created as a usercontrol and then this is added to the web part and the web part is on the page.

I thought on reload of the page the controls were removed the request processed then it was all rendered again but this does not seem to be the case. I've never come across this issue before with any other user control and I am very confused.

1

1 Answers

0
votes

Postback is the reason... When you do sorting, the page reloads and the grid gets recreated. Did you try using (!Page.IsPostBack) { } ?