how to get the value of a selectedItem ? I ve tried :

@using (Html.BeginForm("Index","Product", FormMethod.Post , new { @class = "pure-form pure-form-stacked" }))
           {

    <label for="state">Category</label>
                        <select name="cat" id="cat" class="pure-input-1-2" style="width:200px!important">

                            <option value="99">All Categories...</option>
                            <option value="100">In Promotion </option>


                            @foreach (var c in categories)
    {

        <option value="@c.idCategory">@c.name</option>

    }

                        </select>

and in my Controller I have this Method using FormCollection :

[HttpPost]
public ActionResult Index(FormCollection collection)
        {
            try
            {

                int cat = Int32.Parse(collection["cat"]);

                var result = utOfW.ProductRepository.GetMany(p => p.category.idCategory==cat).ToList();

                return View(result);
            }
            catch
            {
                return View();
            }
        }

it seems to be Ok but it does not work !! SomeOne have an Idea ? Thankxxx...

Related posts

Recent Viewed