1

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. :-)

1 Answer 1

5

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

<input type="hidden" name="page" value="<%=Request.QueryString["page"]%>" />
Sign up to request clarification or add additional context in comments.

1 Comment

Sweet, works great. I'll figure out how to do it for actionlinks. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.