protected void rptRuntimeProperties_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                DropDownList drdAvaiableValues = e.Item.FindControl("drdAvaiableValues") as DropDownList;
                TextBox      txtPropertyValue  = e.Item.FindControl("txtPropertyValue") as TextBox;

                if (drdAvaiableValues != null && txtPropertyValue != null)
                {
                    ArrayList           properties = module.GetAvaiblePropertyValues(true, ((DataRowView)e.Item.DataItem)["Name"].ToString());
                    ModulePropertyValue property;
                    if (properties.Count > 0)
                    {
                        for (int i = 0; i < properties.Count; i++)
                        {
                            property = (ModulePropertyValue)properties[i];
                            drdAvaiableValues.Items.Add(new ListItem(property.AvaiableKey, property.AvaiableValue));
                        }
                        try
                        {
                            drdAvaiableValues.SelectedValue = txtPropertyValue.Text;
                        }
                        catch { }
                        txtPropertyValue.Visible  = false;
                        drdAvaiableValues.Visible = true;
                    }
                    else
                    {
                        txtPropertyValue.Visible  = true;
                        drdAvaiableValues.Visible = false;
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Thủ tục nạp danh sách các tham số thực thi của Module - Cho them truong hop load cac tham so truyen vao duoc lay tu Cat
        /// De lam duoc the thi quy uoc mot danh dau nao do.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rptRuntimeProperties_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                // Lấy danh sách các gái trị cho sẵn của tham số đang xét
                ArrayList _arrAvaiableValues = _module.GetAvaiblePropertyValues(true, DataBinder.Eval(e.Item.DataItem, "Name").ToString());

                // Tìm điều khiển hiển thị danh sách các giá trị cho sẵn
                DropDownList _drdAvaiableValues = e.Item.FindControl("drdAvaiableValues") as DropDownList;

                // Tìm điều khiển hiển thị giá trị nhập bằng tay của tham số đang xét
                TextBox _txtPropertyValue = e.Item.FindControl("txtPropertyValue") as TextBox;

                if (_drdAvaiableValues != null && _arrAvaiableValues != null && _arrAvaiableValues.Count > 0)
                {
                    _drdAvaiableValues.Visible = true;
                    _txtPropertyValue.Visible  = false;

                    // Hiển thị danh sách các giá trị cho sẵn của tham số đang xét
                    ArrayList _arrDisplayPropertyValues = new ArrayList();
                    foreach (ModulePropertyValue _objPropertyValue in _arrAvaiableValues)
                    {
                        _arrDisplayPropertyValues.Add(new ModulePropertyValueDisplayItem(_objPropertyValue.AvaiableKey, _objPropertyValue.AvaiableValue));
                    }
                    _drdAvaiableValues.DataTextField  = "AvaiableKey";
                    _drdAvaiableValues.DataValueField = "AvaiableValue";
                    _drdAvaiableValues.DataSource     = _arrDisplayPropertyValues;
                    _drdAvaiableValues.DataBind();
                    //Cho nay co the quy dinh them datasource co the load tu cat ra.
                    // Chọn lại giá trị tương ứng trong danh sách các giá trị có sẵn.
                    object   _strSelectedPropertyValue     = DataBinder.Eval(e.Item.DataItem, "Value");
                    ListItem _objSelectedPropertyValueItem = _drdAvaiableValues.Items.FindByValue(_strSelectedPropertyValue == null ? "" : _strSelectedPropertyValue.ToString());
                    if (_objSelectedPropertyValueItem != null)
                    {
                        _objSelectedPropertyValueItem.Selected = true;
                    }
                }
                else
                {
                    string strName = DataBinder.Eval(e.Item.DataItem, "Name").ToString();
                    //Neu truong hop lay cat lam thuoc tinh de set thi ten truyen vao dat cung la "catparam"
                    if (strName.ToLower() == "catparam")
                    {
                        Portal.BO.Editoral.Category.CategoryHelper.bindAllCat(_drdAvaiableValues);
                        _drdAvaiableValues.SelectedValue = DataBinder.Eval(e.Item.DataItem, "Value").ToString();
                        _drdAvaiableValues.Visible       = true;
                        _txtPropertyValue.Visible        = false;
                    }
                    else
                    {
                        _drdAvaiableValues.Visible = false;
                        _txtPropertyValue.Visible  = true;
                    }
                }
            }
        }