asp.net - Why won't my search box return any results? -


i using asp.net mvc5 , trying add textbox above table search items in table. in view have

@using (html.beginform()) {    <p>        find start/end point @html.textbox("searchstring")        <input type="submit" value="search" />    </p> } 

then in controller

public actionresult index(string sortorder, string searchstring) {     var lift = l in db.lifts select l;     if (!string.isnullorempty(searchstring))     {         lift = lift.where(l => l.startpoint.contains(searchstring)                                 || l.endpoint.contains(searchstring));     }         return view(lifts.tolist());     } } 

however returns same table every time. silly doing wrong can't see.

try using this:

@using (html.beginform("index","controllername",new { sortorder = "desc/asc" },formmethod.post))                     {                         <p>                         find start/end point @html.textbox("searchstring")                             <input type="submit" value="search" /></p>                     } 

action code:-

public actionresult index(string sortorder, string searchstring)         {             var lift = l in db.lifts select l;             if (!string.isnullorempty(searchstring))             {                 lift = lift.where(l => l.startpoint.contains(searchstring)                                        || l.endpoint.contains(searchstring));             }              return view(lifts.tolist());             }         } 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -