开发者

How to dynamically bind data to label in asp.net mvc

开发者 https://www.devze.com 2023-02-08 19:24 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号