HashTable数据库int型,前台字符显示

public class AppConstant中

#region 公告分类状态
        public static Hashtable StatusHash = new Hashtable
        {
           {"0","全部"}, {"1","公司行规"},{"2","职场秘籍"},{"3","生活小提示"},{"4","电视剧场"},{"5","家庭影院"},{"6","购物广场"}
        };
        public static Hashtable GetOrderStatusHashTable()
        {
            return StatusHash;
        }
        #endregion

repeater显示:

 <td>
           <%-- <%# Eval("[分类]")%>--%>
           <%# AppConstant.GetOrderStatusHashTable()[DataBinder.Eval(Container.DataItem, "分类").ToString()]%>
</td>

-------------------------------------------------------------------------------------------------------------------

控件显示:

 <asp:DropDownList runat="server" ID="txtClass" Width="129px">
                                                    <asp:ListItem Value="0" Selected="True">全部</asp:ListItem>
                                                    <asp:ListItem Value="1">公司行规</asp:ListItem>
                                                    <asp:ListItem Value="2">职场秘籍</asp:ListItem>
                                                    <asp:ListItem Value="3">生活小提示</asp:ListItem>
                                                    <asp:ListItem Value="4">电视剧场</asp:ListItem>
                                                    <asp:ListItem Value="5">家庭影院</asp:ListItem>
                                                    <asp:ListItem Value="6">购物广场</asp:ListItem>
                           </asp:DropDownList>

 

或者:

   string  txtClass1= dt.Rows[0][0].ToString();

 foreach (System.Collections.DictionaryEntry temp in card)//绑定分类类型
            {
                this.txtClass.Items.Add(new ListItem(temp.Value.ToString(), temp.Key.ToString()));
                if (txtClass1 == temp.Key.ToString())
                {
                    this.txtClass.Text = temp.Key.ToString();
                }
            }

posted @ 2012-12-24 10:54  翠儿  阅读(346)  评论(0编辑  收藏  举报