How do I bind a database field to an HTML TITLE element in ASP.NET 2.0?
问题 I know how to do this in MVC: <title> <%= Model.Title %> </title> I also know how to bind a SQLDataSource or ObjectDataSource to a control on a form or listview. But how do I render a field from my SQLDataSource or ObjectDataSource directly into the HTML? 回答1: You can declare a property and set its value using your desired field's value. Code-behind: private string myTitle; protected string MyTitle { get { return myTitle; } set { myTitle = value; } } protected void Page_Load(object sender,