Popular Posts
Build an OpenVPN server on android device Preparation An android device, in this case, Sony xperia Z is used Root permission required Linux Deploy for deploy i... executeOrDelayUntilScriptLoaded Executes the specified function if the file containing it is loaded; otherwise, adds it to the pending job queue. ExecuteOrDelayUntilScrip... Multiple line of text limit With Sharepoint Designer, edit the page of list view. Add xsl template as below to override original template. Source template could be foun...
Blog Archive
Stats
Binding with page member
Usually we'll bind controls with data, like SqlDataSource or XMLDataSource. But I found that I could bind member in a container, too. Now, It's convenient to me binding members withing a container for display some messages.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Binding with a member.aspx.cs"
    Inherits="Binding_with_a_member" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Binding with page member</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:FormView ID="FormView1" runat="server" DataKeyNames="ID" DataSourceID="SqlDataSource1">
            <ItemTemplate>
                <div style="text-align: center; font-size: xx-large; color: Red;">
                    <asp:Label ID="Label1" runat="server" Text='<%# GUID %>'></asp:Label>
                </div>
                <div style="text-align: center; font-size: xx-large; color: Blue;">
                    <asp:Label ID="Label2" runat="server" Text='<%# RandomNumber %>'></asp:Label>
                </div>
                <div style="text-align: center; font-size: xx-large; color: Green;">
                    <asp:Label ID="Label3" runat="server" Text='<%# DateTime.Now %>'></asp:Label>
                </div>
            </ItemTemplate>
        </asp:FormView>
    </div>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:brucedbConnectionString %>"
        SelectCommand="SELECT * FROM [GV]"></asp:SqlDataSource>
    </form>
</body>
</html>
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 Binding_with_a_member : System.Web.UI.Page
{
    protected string GUID;
    protected int RandomNumber;
    protected void Page_Load(object sender, EventArgs e)
    {
        GUID = Guid.NewGuid().ToString();
        RandomNumber = new Random().Next(100, 10000);
    }
}