Actually you do not write the data manipulation code directly in a view. You use a controller for such purposes. Views must only be used to represent the data to the client and (
as a best practice) models must be abstracted from a view using the controller.
However, a view triggers a controller by generating a request. Now there are multiple ways in which you can trigger a dynamic code on the controller. One of them is using QueryStrings. You can append a text in the URL so that when controller looks at the URL, it executes a separate code based on that value.
http:
Now, change the value of
query_string
and
value
to make it suitable for your need. Such as,
category=cat
. Controller would be able to handle it as a variable, or you can always request the value using
var value = Request.QueryString["category"];
value
variable would hold cat in this case.