Hashtable

Web.config
<sectionGroup name="groupInfo">
<section name="CheckUp" type="System.Configuration.DictionarySectionHandler,System,Version=1.0.3300.0,Culture=neutral,PublicKeyToken=b77a5c561934e089,Custom=null"/>
</sectionGroup>

<groupInfo>
<CheckUp>
<add key="0″ value="未審核"/>
<add key="1″ value="已完成"/>
<add key="2″ value="需修改"/>
<add key="3″ value="審核中"/>
</CheckUp>
</groupInfo>

函數
public static Hashtable HashCheckUp //科目 key:English, value:Chinese
{
get
{
Hashtable ht = (Hashtable)HttpContext.Current.GetSection(“groupInfo/CheckUp"); //讀取web.config的雜湊表
return ht;
}
}

public static SortedList SortCheckUp //審核選項
{
get
{
Hashtable ht = HashCheckUp;
SortedList sl = new SortedList(ht);
return sl;
}
}

應用
System.Collections.Hashtable ht = Globals.HashCheckUp;
((Label)e.Row.FindControl(“lblDataCheck")).Text = ht[schedule.DataCheck].ToString();

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *