<%@ Page Language="C#" %>
<%@ Import Namespace ="System.Data" %>
<%@ Import Namespace ="System.Data.Common" %>
<%@ Import Namespace ="System.Data.SqlClient" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e) {
DataView dv = Cache["Employees"] as DataView;
if ( dv == null ) {
using ( DbDataAdapter dAdapter = new SqlDataAdapter(
"SELECT * FROM EMPLOYEES",
"server = localhost ; uid=sa ; pwd =; database = ORGANIZATION")){
DataSet ds = new DataSet();
dAdapter.Fill( ds );
dv = ds.Tables[0].DefaultView;
dv.AllowDelete = false;
dv.AllowEdit = false;
dv.AllowNew = false;
Cache.Insert("Employees", dv,
new SqlCacheDependency("DbORGANIZATION","EMPLOYEES"));
} // end using dAdapter.
}
else Response.Write("Loaded from cache!");
MyList.DataSource = dv;
MyList.DataTextField = "SurName";
DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<form id="Form1" runat="server">
<asp:ListBox ID="MyList" runat="server"/>
</form>
</body>
</html>