asp.net DataBind() example: data binding with control properties
DataBindingProperties.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DataBindingProperties.aspx.cs" Inherits="DataBindingProperties" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>asp.net DataBind() example: data binding with control properties</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy">Example: Data Binding with Control Properties</h2>
<asp:Label ID="Label1" runat="server" Font-Size="Large" Text="<%# ImageName %>" ForeColor="CornflowerBlue" Font-Italic="true">
</asp:Label>
<br />
<asp:Image ID="Image1" runat="server" ImageUrl="<%# ImageUrl %>" />
</div>
</form>
</body>
</html>
DataBindingProperties.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class DataBindingProperties : System.Web.UI.Page
{
public string ImageName;
public string ImageUrl;
protected void Page_Load(object sender, EventArgs e)
{
ImageName = "Sea Beach";
ImageUrl = "~/Images/SeaBeach.jpg";
this.DataBind();
}
}