Hi ramco1917,
Check this example. Now please take its reference and correct your code.
Model
public class Item
{
public int Id { get; set; }
public string Description { get; set; }
public string IsActive { get; set; }
}
Controller
public class HomeController : Controller
{
public ActionResult Index()
{
List<Item> items = new List<Item>();
items.Add(new Item()
{
Id = 1,
Description = "Desc 1",
IsActive = "N"
});
items.Add(new Item()
{
Id = 2,
Description = "Desc 2",
IsActive = "Y"
});
return View(items);
}
}
View
@model IEnumerable<Model_Table_MVC.Models.Item>
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
</head>
<body>
<table class="table">
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.IsActive)
</td>
<td>
<a class='btn btn-primary btn-sm' id='btnEdit'><i class='fa fa-pencil'></i> Edit</a>
@if (item.IsActive.ToUpper() == "N")
{
<a class='btn btn-danger btn-sm disabled' id='btnDelete' style='margin-left:5px'><i class='fa fa-trash'></i> Delete</a>
}
else
{
<a class='btn btn-danger btn-sm' id='btnDelete' style='margin-left:5px'><i class='fa fa-trash'></i> Delete</a>
}
</td>
</tr>
}
</table>
</body>
</html>
Screenshot