How to dynamically bind data to label in asp.net mvc
How to dynamically bind data to label in Asp.net MVC. I have table where i need to display all compnay name dayanamically. I did create a Model for compnay name.
code in model look like this,开发者_开发知识库
public class CompnayName
{
public string compnayName { get; set; }
public string address { get; set; }
}
Please first correct spelling of the class name ;-)
Your asp page needs to inherit from your model:
Inherits="System.Web.Mvc.ViewPage<namespace.CompanyName>"
Then uses LabeFor:
<%= Html.LabelFor(m => Model.companyName)%>
That should do the trick.
精彩评论