The following Model holds Registration details
public class Registration
{
public int RegistrationID { get; set; }
[Required(ErrorMessage = "Enter Name")]
public string Name { get; set; }
[Required(ErrorMessage = "Mobileno Required")]
[Display(Name = "Mobile No")]
[RegularExpression(@"^(\d{10})$", ErrorMessage = "Wrong Mobileno")]
public string Mobileno { get; set; }
[Required(ErrorMessage = "EmailID Required")]
[Display(Name = "Email")]
public string EmailID { get; set; }
}
The following holds assigned Records to users in the Registration Model above
public class AssignedRoles
{
[Key]
public int AssignedRolesID { get; set; }
public int? AssignToAdmin { get; set; }
public int? CreatedBy { get; set; }
public DateTime? CreatedOn { get; set; }
public int RegistrationID { get; set; }
public string Status { get; set; }
public DateTime? ModifiedOn { get; set; }
[DataType(DataType.Time)]
public string TurnAroundTime { get; set; }
public virtual Incidence Incidence { get; set; }
public int RegID { get; set; }
}
Below is the view
<table id="example1" class="table table-striped table-bordered">
<thead>
<tr>
<th>TSC NO</th>
<th>Name</th>
<th>Cell</th>
<th>Request</th>
<th>Request Type</th>
<th>Incidence Type</th>
<th>Duration</th>
<th>Assigned To</th>
</tr>
</thead>
@foreach (var item in Model)
{
<tr>
<td>@item.Incidence.TSCNO</td>
<td>@item.Incidence.Name</td>
<td>@item.Incidence.CellPhone</td>
<td>@item.Incidence.Request</td>
<td>@item.Incidence.RequestType</td>
<td>@item.Incidence.IncidenceType</td>
<td>@item.TurnAroundTime</td>
<td>Username goes here</td>
</tr>
}
</table>
Whenever an item is assigned to a user, the registrationID
which serves as the UserID
is pushed to the AssignToAdmin
column in AssignedRoles
.
However, from the view, I would like to display the Name
of the Admin instead of the ID
.