asp.net mvc - Can an Html.Actionlink pass the selected value of a dropdownlist? -


i have mvc razor page have 2 html action links work fine separately, not together. before looking jquery option, wanted make sure wasn't missing obvious. hoping keep things simple adding second parameter relevant html.actionlink.

i making transition web pages mvc, gathered have far looking @ examples on microsoft asp.net learning resources , other posts.

these current (relevant) sections of cshtml page.

first action (filter dropdown): @ top of page have dropdown can filter form 1 column value. itself, works great.

@using (html.beginform()) {   <p>     filter campus: @html.dropdownlist("searchbyfilter", new selectlist(viewbag.names))      <input type="submit" value="filter" />   </p> } 

second action (sort column): in header row of table, have action link, when user clicks column header, controller serves table sorted appropriately. i'm showing single column out of table show how works.

<th>                            @html.actionlink("campus", "index", new { orderby = viewbag.campussortparm })        </th> 

the problem: while these work great independently -- obvious reasons, 2 action links don't work together. hoping keep things simple , this, adding second parameter can read value of dropdown (null not option).

<th>                            @html.actionlink("campus", "index", new { orderby = viewbag.campussortparm     @*, searchbyfilter = selected value of searchbyfilter dropdown, how here? *@  }) </th> 

can add second parameter in fashion, or need jquery solution?

thanks @stephen muecke confirming question posed needed done in jquery or javascript.

however, after asking myself why code able work far, thought of obvious change make. rather sorting column click, make part of form submission.

@using (html.beginform()) { <div>     <p>         filter campus: @html.dropdownlist("searchby", new selectlist(viewbag.names))     </p>     <p>         <strong>sort column: </strong>         @html.dropdownlist("orderby", new selectlist (viewbag.sortbycolumns))     </p>     <p>         <strong>sort direction: </strong>                     @html.dropdownlist("orderdir", new selectlist(viewbag.sortdir))     </p>     <input type="submit" value="apply" /> </div> } 

this works needs. result of question achieved.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -