zoukankan      html  css  js  c++  java
  • 页面中的传参介质(ViewState,Session,Items),Dictionary的用法.

    1例.
    private List<int> QuotationIds            //List<int>可以是List<string>,bool,class(类),int,string...
       
    {
            get
            {
                object o = ViewState["QuotationIds"];    //ViewState可以是Session,Items.
                if (o == null)
                {
                    o = new List<int>();
                    ViewState.Add("QuotationIds", o);
                }
                return (List<int>)o;
            }
            set
            {
                ViewState["QuotationIds"] = value;
            }
        }

    2例.
    private string PartWhere
        {
            get
            {
                object o = ViewState["PartWhere"];
                if (o == null)
                    o = string.Empty;

                return (string)o;
            }
            set
            {
                ViewState["PartWhere"] = value;
            }
        }

    3例.
    private int[] QuotationIDs
        {
            get
            {
                return (int[])Items["QuotationIDs"];
            }
            set
            {
                Items["QuotationIDs"] = value;
            }
        }
    4.protected Bid CurrentBid            //Bid是一个类
        {
            get
            {
                return (Bid)Session["CurrentBid"];
            }
            set
            {
                Session["CurrentBid"] = value;
            }
        }

    5.protected Dictionary<string, string> ToolNames   //<string,string>这里的类型可以自己设定,可以为<int,int>,也可以为<int,string>
        {
            get
            {
                object o = ViewState["ToolNames"];
                if (o == null)
                {
                    o = new Dictionary<string, string>();
                    ViewState.Add("ToolNames", o);
                }
                return (Dictionary<string, string>)o;
            }
        }

  • 相关阅读:
    浅谈 IBM 购并 Sun Microsystems
    用 CSS 替代 HTML 的 table tag 设计网页版面
    用 IIS 7、ARR 與 Velocity 建设高性能的大型网站
    实作 ASP.NET 多笔数据离线编辑
    快速搞懂 ASP.NET MVC
    C# Design Patterns (2) Strategy
    网站性能越来越差怎么办?
    dotNET 类型转型的三种做法
    ASP.NET 数据分页第二篇 范例下载
    程序员真情忏悔录
  • 原文地址:https://www.cnblogs.com/qfb620/p/1245074.html
Copyright © 2011-2022 走看看