zoukankan      html  css  js  c++  java
  • ASP.NET2.0 缓存(Cache)技术介绍

    觉得自定义控件中加入缓存,从而实现整个页的局部缓存,效果不错。

    自定义控件在前台加入:

    <%@ OutputCache Duration="60" VaryByParam="none" %>

    后台代码: 

       protected void Page_Load(object sender, EventArgs e)
        
    {
            Label1.Text 
    = DateTime.Now.ToString();

            source 
    = (DataView)Cache["SQUARE"];

            
    if (source == null)
            
    {
                conn 
    = new SqlConnection(ConfigurationManager.ConnectionStrings["GoConnectionString"].ConnectionString);
                mycmd 
    = new SqlDataAdapter("select * from GUser", conn);

                DataSet ds 
    = new DataSet();

                mycmd.Fill(ds, 
    "GUser");

                source 
    = new DataView(ds.Tables["GUser"]);

                Cache[
    "SQUARE"= source;

            }

            
    else 
            
    {
               
            }

            
            GridView1.DataSource 
    = source;
            GridView1.DataBind();
        }
  • 相关阅读:
    目录路径加反斜杠和不加的区别
    window端口号被占用解决
    个人博客设计记录
    2017/12/15
    添加code到github上
    跨域简介
    客户端存储
    window.name跨域
    BZOJ1305: [CQOI2009]dance跳舞
    BZOJ4872: [Shoi2017]分手是祝愿
  • 原文地址:https://www.cnblogs.com/shengel/p/804116.html
Copyright © 2011-2022 走看看