ASP.NET DataBind() example - Data binding with control properties DataBind() example: data binding with control properties

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DataBindingProperties.aspx.cs" Inherits="DataBindingProperties" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
    <title> DataBind() example: data binding with control properties</title>
    <form id="form1" runat="server">
        <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">
        <br />
        <asp:Image ID="Image1" runat="server" ImageUrl="<%# ImageUrl  %>" />

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";
More examples