using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text; using System.Threading; namespace WebTest { using DotNet.Common.WebForm; using DotNet.Common.Model; using EntCor.Hrm.Model; public partial class _Default : BasePage { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Employee employee = new Employee { ID = 1, UserName = "jeff wong", Address = "北京", IsLeave = false, RealName = "测试用户", State = "2" }; this.SetFormData(employee); //给页面控件赋值 } } } }
3、使用反射给对象赋值
点击”测试”按钮,将页面控件(runat=server)的值赋给实体对象: