Question

I'm building a grid in ASP.NET MVC and I have the following issue:

  • Above the grid i have a column selector which lets people customize the columns being shown. This is a form with a submit button so that people can add/remove multiple columns at once without going trough multiple postbacks.
  • Below the grid I have paging. This is paging trough actionlinks (a href's).

alt text http://thomasstock.net/mvcget.jpg

What happens when a user add/removes columns is that the form gets submitted to http://localhost:56156/?columnsToDisplay=EmployeeId and ofcourse the grid jumps back to page 1. I'd like to keep the grid on the page the user was currently on. So I need a way to include the current querystring parameters into the form's action attribute.

The other way around too: I need a way to do the same with actionlinks. But this is less necessary as I could always replace the a href's with buttons and put them in a form. But I'd rather not do that.

I'm looking for a solution without javascript! I can do it myself in javascript, but I'd like my grid to work perfectly on javascript-disabled browsers.

Any help is appreciated.

Edit: Oh yeah, to make it a bit harder, I'm also looking for a solution without cookies/session variables. :-)

Was it helpful?

Solution

You need to add the line below into your column selector form

<input type="hidden" name="page" value="<%=Request.QueryString["page"]%>" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top