Frage

I am trying to make this code a partial view to add alpha paging to my grids:

<div class="t-pager-wrapper" style="border-bottom:0">
        <div class="t-pager t-reset">                                
            @foreach (var letter in CollectionUtil.Alphabet){
                @Html.ActionLink(letter, "Index", new { Equipment_filter = "Equipment.Name~startswith~'" + letter + "'" }, new { @class = "t-link" })
            }
            @Html.ActionLink("All", "Index")                                                       
        </div>
    </div>

How can I pass in the name "Equipment" to use as the parameter in the query string? All of my grids have their own name for their data, so in order for the paging filter to work it would be different on each page, Equipment_filter, Color_filter, Cars_filter, etc.

So example URLs would be:

http://www.mydomain.com/Equipment?Equipment-filter=Equipment.Name~startswith~'B'
http://www.mydomain.com/Color?Color-filter=Color.Name~startswith~'C'

So I would need to have parameters to pass into the partial being "Equipment" for the filter prefix, and "Equipment.Name" for the path to make the object property comparison with.

EDIT:

Well I did this by just using Url.Action inside the href parameter of a link instead:

<a href="@Url.Action("index")?Equipment-filter=Equipment.Name~startswith~'@letter'">@letter</a>

At which point supplying "Equipment" and "Equipment.Name" are trivial since everything is a string. If someone wants to post a solution using ActionLink I will mark that as the answer though.

War es hilfreich?

Lösung

Well I did this by just using Url.Action inside the href parameter of a link instead:

<a href="@Url.Action("index")?Equipment-filter=Equipment.Name~startswith~'@letter'">@letter</a>

At which point supplying "Equipment" and "Equipment.Name" are trivial since everything is a string.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top