Exemplo n.º 1
0
    protected void rptDictionaryItem_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        //
        // <a href="javascript:Edit('<%# Eval("ItemCode")%>',true)">新增子项</a>
        RepeaterItem   item  = e.Item;
        DictionaryItem group = item.DataItem as DictionaryItem;

        if (group != null && group.ItemType == DictionaryItemType.Group)
        {
            Panel panel = item.FindControl("OperationPanel") as Panel;
            if (panel != null)
            {
                HtmlAnchor ank = new HtmlAnchor();
                ank.HRef      = string.Format("javascript:Edit('{0}',true)", group.ItemCode);
                ank.InnerText = "新增子项";
                panel.Controls.Add(ank);
            }
            Repeater rptSubItems = item.FindControl("rptSubItems") as Repeater;

            if (rptSubItems != null)
            {
                IList <DictionaryItem> subItems = DictionaryItem.GetDictionaryItemsByGroup(_session, group.ItemCode);
                if (subItems != null && subItems.Count > 0)
                {
                    rptSubItems.DataSource = subItems;
                    rptSubItems.DataBind();
                }
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 绑定词汇表项
    /// </summary>
    /// <param name="session"></param>
    /// <param name="listCtrl"></param>
    /// <param name="groupCode"></param>
    public static void BindDictionaryItems2ListControl(ISession session, ListControl listCtrl, string groupCode)
    {
        IList <DictionaryItem> list = DictionaryItem.GetDictionaryItemsByGroup(session, groupCode);

        if (list != null && list.Count > 0)
        {
            foreach (DictionaryItem itm in list)
            {
                ListItem item = new ListItem();
                item.Text  = itm.Name;
                item.Value = itm.ValueToString;
                listCtrl.Items.Add(item);
            }
        }
    }