home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / aspplus / samples / cache / outputcache3.aspx < prev    next >
Encoding:
Text File  |  2000-05-30  |  2.3 KB  |  79 lines

  1. <%@ OutputCache Duration="10" %>
  2. <%@ Import Namespace="System.Data" %>
  3. <%@ Import Namespace="System.Data.SQL" %>
  4.  
  5. <html>
  6.  
  7.   <script language="C#" runat="server">
  8.  
  9.     void Page_Load(Object Src, EventArgs E ) {
  10.     
  11.           String selectCmd;
  12.           String state = Request["state"];
  13.  
  14.           if( state == null ) {
  15.               selectCmd = "select * from Authors";
  16.           }
  17.           else {
  18.                 selectCmd = "select * from Authors where state = '" + state + "'";
  19.           }
  20.  
  21.         SQLConnection myConnection = new     SQLConnection("server=localhost;uid=sa;pwd=;database=pubs");
  22.         SQLDataSetCommand myCommand = new SQLDataSetCommand(selectCmd, myConnection);
  23.  
  24.         DataSet ds = new DataSet();
  25.         myCommand.FillDataSet(ds, "Authors");
  26.  
  27.         MyDataGrid.DataSource=new DataView(ds.Tables[0]);
  28.         MyDataGrid.DataBind();
  29.         
  30.           // capture the time of the current request
  31.           // subsequent requests that are cached will show the
  32.           // original time
  33.         
  34.           TimeMsg.Text = DateTime.Now.ToString();    
  35.     }
  36.  
  37.   </script>
  38.  
  39.   <body>
  40.     <h3><font face="Verdana">Using the Output Cache</font></h3>
  41.  
  42.     <b>Authors by State:</b>
  43.     
  44.     <table cellspacing="0" cellpadding="3" rules="all" style="background-color:#AAAADD;border-color:black;border-color:black;width:700px;border-collapse:collapse;">
  45.             <tr>
  46.               <td><a href="outputcache3.aspx?state=CA">CA</a></td>
  47.               <td><a href="outputcache3.aspx?state=IN">IN</a></td>
  48.               <td><a href="outputcache3.aspx?state=KS">KS</a></td>
  49.               <td><a href="outputcache3.aspx?state=MD">MD</a></td>
  50.               <td><a href="outputcache3.aspx?state=MI">MI</a></td>
  51.               <td><a href="outputcache3.aspx?state=OR">OR</a></td>
  52.               <td><a href="outputcache3.aspx?state=TN">TN</a></td>
  53.               <td><a href="outputcache3.aspx?state=UT">UT</a></td>
  54.         </tr>
  55.     </table>
  56.     
  57.     <p>
  58.  
  59.     <ASP:DataGrid id="MyDataGrid" runat="server"
  60.         Width="700"
  61.         BackColor="#ccccff" 
  62.         BorderColor="black"
  63.         ShowFooter="false" 
  64.         CellPadding=3 
  65.         CellSpacing="0"
  66.         Font-Name="Verdana"
  67.         Font-Size="8pt"
  68.         HeaderStyle-BackColor="#aaaadd"
  69.     />
  70.         
  71.     <p>
  72.     
  73.     <i>Last generated on:</i> <asp:label id="TimeMsg" runat="server"/>
  74.     
  75.   </body>
  76. </html>
  77.  
  78.  
  79.