home *** CD-ROM | disk | FTP | other *** search
- <%@ OutputCache Duration="10" %>
- <%@ Import Namespace="System.Data" %>
- <%@ Import Namespace="System.Data.SQL" %>
-
- <html>
-
- <script language="C#" runat="server">
-
- void Page_Load(Object Src, EventArgs E ) {
-
- String selectCmd;
- String state = Request["state"];
-
- if( state == null ) {
- selectCmd = "select * from Authors";
- }
- else {
- selectCmd = "select * from Authors where state = '" + state + "'";
- }
-
- SQLConnection myConnection = new SQLConnection("server=localhost;uid=sa;pwd=;database=pubs");
- SQLDataSetCommand myCommand = new SQLDataSetCommand(selectCmd, myConnection);
-
- DataSet ds = new DataSet();
- myCommand.FillDataSet(ds, "Authors");
-
- MyDataGrid.DataSource=new DataView(ds.Tables[0]);
- MyDataGrid.DataBind();
-
- // capture the time of the current request
- // subsequent requests that are cached will show the
- // original time
-
- TimeMsg.Text = DateTime.Now.ToString();
- }
-
- </script>
-
- <body>
- <h3><font face="Verdana">Using the Output Cache</font></h3>
-
- <b>Authors by State:</b>
-
- <table cellspacing="0" cellpadding="3" rules="all" style="background-color:#AAAADD;border-color:black;border-color:black;width:700px;border-collapse:collapse;">
- <tr>
- <td><a href="outputcache3.aspx?state=CA">CA</a></td>
- <td><a href="outputcache3.aspx?state=IN">IN</a></td>
- <td><a href="outputcache3.aspx?state=KS">KS</a></td>
- <td><a href="outputcache3.aspx?state=MD">MD</a></td>
- <td><a href="outputcache3.aspx?state=MI">MI</a></td>
- <td><a href="outputcache3.aspx?state=OR">OR</a></td>
- <td><a href="outputcache3.aspx?state=TN">TN</a></td>
- <td><a href="outputcache3.aspx?state=UT">UT</a></td>
- </tr>
- </table>
-
- <p>
-
- <ASP:DataGrid id="MyDataGrid" runat="server"
- Width="700"
- BackColor="#ccccff"
- BorderColor="black"
- ShowFooter="false"
- CellPadding=3
- CellSpacing="0"
- Font-Name="Verdana"
- Font-Size="8pt"
- HeaderStyle-BackColor="#aaaadd"
- />
-
- <p>
-
- <i>Last generated on:</i> <asp:label id="TimeMsg" runat="server"/>
-
- </body>
- </html>
-
-
-