This project is read-only.

How to pass data to the Controller?

Sep 23, 2016 at 8:06 PM
I am missing a very important function.
My scenario: I am making a request to a controller with a value. The value is sent to the database and I get my data. The data is shown on the grid. All values are there. Now I click on a column-header for new sorting and the same controller-method recieves a request. My model, which gets send to the controller has no values. So the request to the database can not happen, cause the needed parameter is null. How can I modify the click on the column-header for ordering, so that my controller recieves the model with the filled value I need for the database-request? Client-side sorting would be also cool. I just want to send one value to the controller, when I click on the column-header, but why?
Sep 24, 2016 at 10:59 AM
It seems the magic is not to use a form, since the sort-request can not access values, that are inside a form, even if they are in a hiddenfor outside the form. Took me one day to to get it solved :(
Oct 17, 2016 at 12:47 PM
Edited Oct 17, 2016 at 1:56 PM
Found answer there, when I posted I gave a custom name for the post method in the controller this meant that my grid view url had this added to end.

To fix I rename my port method as Index, adding parms and that prevents the report url form changing.

Used this reference info ~

TEXT


Hi there,

I am having a similar issue, I created a grid successfully which column sorted and filtered fine. The I added a couple of datepikcer controls seperately with a form to post back and refresh the model, if I use the date filters though anytime I click the column sorting after it tries to submit to that same http method, and I get an unknown address.

Essentially I don't want it trying to post to my controller method after I refilter my dates. How do you avoid using a form to do the postback in this scenario? I am also planning on implementing an export function so will have multiple controller post methods.

Thanks,
N