I have following code in my Details View of Entity A
<dt>
@Html.DisplayNameFor(model => model.User1.UserName)
</dt>
<dd>
@Html.DisplayFor(model => model.User1.UserName)
</dd>
I want to change their title that is shown in Details View
it is showing UserName where i want it to be Submitted by
it cant be overloaded because DisplayName For donot have any overloaded function with two params
@Html.DisplayFor(model => model.User1.UserName,"Submitted By")
Not working
any Help
Here is my Model of Bugs Where i have Fields of Assigned to and submitted by which are related to the users model so i am having problem that "UserName" is shown at the place of column Name where it should show the Names as "Assigned To" and "Submitted By"
public partial class Bug
{
public int ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Priority { get; set; }
public string Severity { get; set; }
public string Status { get; set; }
public int AssignedTo { get; set; }
public int SubmittedBy { get; set; }
public int ComponentID { get; set; }
public int ProjectID { get; set; }
public System.DateTime DueDate { get; set; }
public Nullable<int> BugNumber { get; set; }
public string NormalFlow { get; set; }
public System.DateTime CreationDate { get; set; }
public virtual Component Component { get; set; }
public virtual Project Project { get; set; }
public virtual User User { get; set; }
public virtual User User1 { get; set; }
}
You can control the displayed text via the [Display] attribute on your model. In your case you'd want to set the attribute on the underlying model for User1:
public class User
{
[Display(Name = "Submitted By")]
public string UserName;
}
See https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displayattribute.name%28v=vs.110%29.aspx for more details on the DisplayAttribute class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With