//ball public List<mone> searchajax(string search) { List<mone> lst = new List<mone>(); lst = (from p in db.onetbls where p.name.Contains(search) select new mone { id = p.id, name = p.name, city = p.city, state = p.state, comments = p.cournt, cournt = p.cournt, }).ToList<mone>(); return lst; }
//controller public ActionResult search(string search) { ViewBag.search = new SelectList(db.onetbls, "id", "name"); List<mone> lst = new List<mone>(); lst = lc.searchajax(search); return View(lst); }
//view @model IEnumerable<bal.models.mone> @{ ViewBag.Title = "search"; } <h2>search</h2> @using(Html.BeginForm()) { @*@Html.TextBox("search")*@ @Html.DropDownList("search", "select") <input type="submit" /> } <p> @Html.ActionLink("Create New", "Create") </p> <table class="table"> <tr> <th> @Html.DisplayNameFor(model => model.name) </th> <th> @Html.DisplayNameFor(model => model.city) </th> <th> @Html.DisplayNameFor(model => model.state) </th> <th> @Html.DisplayNameFor(model => model.cournt) </th> <th> @Html.DisplayNameFor(model => model.img) </th> <th> @Html.DisplayNameFor(model => model.email) </th> <th> @Html.DisplayNameFor(model => model.gender) </th> <th> @Html.DisplayNameFor(model => model.oid) </th> <th> @Html.DisplayNameFor(model => model.comments) </th> <th> @Html.DisplayNameFor(model => model.fid) </th> </tr> @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.name) </td> <td> @Html.DisplayFor(modelItem => item.city) </td> <td> @Html.DisplayFor(modelItem => item.state) </td> <td> @Html.DisplayFor(modelItem => item.cournt) </td> <td> @Html.DisplayFor(modelItem => item.img) </td> <td> @Html.DisplayFor(modelItem => item.email) </td> <td> @Html.DisplayFor(modelItem => item.gender) </td> <td> @Html.DisplayFor(modelItem => item.oid) </td> <td> @Html.DisplayFor(modelItem => item.comments) </td> <td> @Html.DisplayFor(modelItem => item.fid) </td> </tr> }
string[] s = new string[] { "aa", "bb" }; List<string> lst = new List<string>(); for (int i = 0; i < s.Length; i++) { if (s[i].Contains("")) lst.Add(s[i]); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)