如何在重定向到PagedList的下一页时保留下拉列表的选定值和文本

时间:2014-05-13 08:53:46

标签: html5 asp.net-mvc-4 razor-2

如何在重定向到pagedList的下一页时保留下拉列表的选定值和文本。因为我'对于MVC世界来说,任何帮助都会得到很大的帮助。 在此先感谢。

这是我的观点

         @using (Html.BeginForm("ViewDataOfDatabase", "AirtelManagement",FormMethod.Post))
{
<h3>Search by PhoneNumber:@Html.TextBox("SearchString",ViewBag.CurrentFilter as string)</h3>


    <p><h3>Year:@Html.DropDownList("Yearitems",(IEnumerable<SelectListItem>)ViewBag.SelectList, "Select Year")</h3>
    <h3>Month:@Html.DropDownList("MonthItems",(IEnumerable<SelectListItem>)ViewBag.SelectMonthList,"Select Month")</h3>
    <h3>City: @Html.DropDownList("CityNames",(IEnumerable<SelectListItem>)ViewBag.CityList,"Select City")</h3></p>

<p><input type="submit" value="Search" /></p>

<script>
    $(document).ready(function () {
        $("#Yearitems").change(function () {
            //debugger;
            //alert($("#Yearitems>option:selected").attr("Value"));
            $.ajax({
                type: "Post",
                url: '@Url.Action("GetMonths","AirtelManagement")',
                data: { YearId: $("#Yearitems>option:selected").attr("Value") },
                datatype: "Json",
                success: function (data) {
                    //debugger;
                    $("#MonthItems").html("");
                    $.each(data, function (index, item) {
                        $("#MonthItems").append(new Option(item.MonthName, item.MonthSelectedId));
                    });
                },
                error: function () {
                    alert("Select Year");
                }
            });
        });
    });
</script>

}

     <table border="1">
      <tr>
    <th>
        MobileAcNumber
    </th>
    <th>
        AirtelNumber
    </th>
    <th>
        OneTime
    </th>
    <th>
        MonthlyCharges
    </th>
    <th>
        CallCharges
    </th>
    <th>
        ValueAddedServices
    </th>
    <th>
        MobileInternetUsage
    </th>
    <th>
        Roaming
    </th>
    <th>
        Discounts
    </th>
    <th>
        Taxes
    </th>
    <th>
        TotalCharges
    </th>
</tr>

@foreach (var item in Model)
        {
        <tr>
            <td style="border: 1px solid">
                @Html.DisplayFor(modelItem => item.MobileAcNumber)
            </td>
            <td style="border: 1px solid">
                @Html.DisplayFor(modelItem => item.AirtelNumber)
            </td>
            <td style="border: 1px solid">
                @Html.DisplayFor(modelItem => item.OneTime)
            </td>
            <td style="border: 1px solid">
                @Html.DisplayFor(modelItem => item.MonthlyCharges)
            </td>
            <td style="border: 1px solid">
                @Html.DisplayFor(modelItem => item.CallCharges)
            </td>
            <td style="border: 1px solid">
                @Html.DisplayFor(modelItem => item.ValueAddedServices)
            </td>
            <td style="border: 1px solid">
                @Html.DisplayFor(modelItem => item.MobileInternetUsage)
            </td>
            <td style="border: 1px solid">
                @Html.DisplayFor(modelItem => item.Roaming)
            </td>
            <td style="border: 1px solid">
                @Html.DisplayFor(modelItem => item.Discounts)
            </td>
            <td style="border: 1px solid">
                @Html.DisplayFor(modelItem => item.Taxes)
            </td>
            <td style="border: 1px solid">
                @Html.DisplayFor(modelItem => item.TotalCharges)
            </td>
        </tr>
        }
     </table>
      <br />
    Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of     @Model.PageCount
@Html.PagedListPager(Model, page => Url.Action("ViewDataOfDatabase","AirtelManagement", new { page,sortOrder=ViewBag.CurrentSort,currentFilter=ViewBag.CurrentFilter}))

0 个答案:

没有答案