How to single value data binding in with c#

How to single value data binding in with c#

 In this article, I am going to explain with example how to create a single value data binding in in both the C#

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

    <!DOCTYPE html>
    <html xmlns="">
    <head id="Head1" runat="server">
        <title> single value data binding example</title>
        <form id="form1" runat="server">
            <h2 style="color:Teal">Example: Single Value Data Binding [Using Variable]</h2>
            <asp:Label ID="Label1" runat="server" Font-Size="Large">
                User ID: <%# UserID %><br />
                UserName: <%# UserName %><br />
                City: <%# City %>

Source Code:-

  1. 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 = "srkcode";
            City = "Lucknow";


Post a Comment