How to keep selected column for sorting?

I use gridview to displaying my data. I can choose filters and do sort with every column. But when I change filters and press submit button the sorted column resets to the first column. How could I keep selected column sorted? I tried to use javascript but it still doesn’t work as I wanted.