asp.net single value data binding - using variable
DataBindingExample.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DataBindingExample.aspx.cs" Inherits="DataBindingExample" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>asp.net single value data binding example: using variable</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Teal">Example: Single Value Data Binding [Using Variable]</h2>
<asp:Label ID="Label1" runat="server" Font-Size="Large" Font-Italic="true" ForeColor="Crimson">
User ID: <%# UserID %><br />
UserName: <%# UserName %><br />
City: <%# City %>
</asp:Label>
</div>
</form>
</body>
</html>
DataBindingExample.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 DataBindingExample : System.Web.UI.Page
{
public int UserID;
public string UserName;
public string City;
protected void Page_Load(object sender, EventArgs e)
{
UserID = 1;
UserName = "Jones";
City = "Rome";
this.DataBind();
}
}
