In my Relation i have two tables relation (one to many)
table country
Id (primary key)
Countryname
table City
Id (primary key)
Cityname
Countryid (forign key)
I have controller City have list of data in city table as following
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LinqProject.Models;
namespace LinqProject.Controllers
{
public class CityController : Controller
{
mytaskdbEntities db = new mytaskdbEntities();
// GET: City
public ActionResult List()
{
return View(db.Cities.ToList());
}
and in view of List as following
<body>
<div>
<table>
@foreach (var item in Model)
{
<tr><td>@item.Cityname</td><td>@item.Country.Countryname</td></tr>
}
</table>
</div>
</body>
What i need actually adding EDIT button to view of list of city
and i can edit row city when click edit button
how to do edit record by linq
the final result as following
USA NEWYORK EDITBUTTON
USA WASHINTON EDITBUTTON
FRANCE PARIS EDITEBUTTON
when click EDIT button for row USA NEWYORK and change it to NEWGERSY it will edit
and records will be after edited as following
USA NEWGERSY EDITBUTTON
USA WASHINTON EDITBUTTON
FRANCE PARIS EDITEBUTTON
how to make edit to row from table using linq
Re: how to make edit to row from table using linq
We have reproduced the issue with missing Edit link on the page generated by the MVC View Advanced template. We will notify you when it is fixed.