mardi 28 avril 2015

Query Selected Items using checkbox in MVC

I like to ask if how would it be possible that the selected items in the checkbox will be used in making linq query in MVC. I have this one in my view where in I displayed all the possible options in which the user will just simply select the types of softwares that will be used to generate reports.

@using (Ajax.BeginForm("Create_Report", "Softwares",
            new AjaxOptions
            {
                HttpMethod = "POST",
                InsertionMode = InsertionMode.Replace,
                UpdateTargetId = "target2"
            })) 
        { 
            @Html.ValidationSummary(true)
             <p>For A Reports: Kindly check softwares to create reports.</p><br />
            foreach (var item in Model) { 
                <input type="checkbox" value="@item.software_name" name="software_type"/>@item.software_name
                <br />
            }


            <input type="submit" value="Create Report"/>

        }

After that, I want that the selected software types will be used in the query like for example if the user selects Adobe Pro, Adobe Illustrator, MS Visio, and Acrobat, the query should go like "Select from Software _table where software__type = "Adobe Pro" && software_type ="Adobe Illustrator && "so fort.

Is there any ways to shorten the query using the selected items from the checkbox? Any help is much appreciated.




Aucun commentaire:

Enregistrer un commentaire