Popular Posts
javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... Close window without confirm (I.E only) window.opener=null; window.open('','_self'); window.close(); focus on validating function focusOnInvalidControl() {     for (var i = 0; i < Page_Validators.length; i++) {         if (!Page_Validators[i].isvalid) {     ...
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);
    }
}