Inheritance: ListControl, IPostBackDataHandler
Example #1
0
        /// <summary>
        /// 读取控件的value到object
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="list"></param>
        public static void ReadControlToObject(object obj, Dictionary <Control, string> list)
        {
            string property = string.Empty;
            Type   ot       = obj.GetType();

            try
            {
                foreach (var i in list)
                {
                    var ti = ot.GetProperty(i.Value);
                    property = ti.Name;
                    var  type = ti.PropertyType;
                    Type pt   = type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>) ? type.GetGenericArguments()[0] : type;//获得非空类型

                    if (i.Key is System.Web.UI.WebControls.TextBox)
                    {
                        System.Web.UI.WebControls.TextBox tmpControl = (System.Web.UI.WebControls.TextBox)i.Key;
                        if (pt == typeof(String) || pt == typeof(string))
                        {
                            ti.SetValue(obj, tmpControl.Text, null);
                        }
                        else if (pt == typeof(decimal) || pt == typeof(int))
                        {
                            if (PFDataHelper.StringIsNullOrWhiteSpace(tmpControl.Text))
                            {
                                ti.SetValue(obj, null, null);//当ti为不可空的属性时,设null值不会报错,值为0
                            }
                            else
                            {
                                if (pt == typeof(decimal))
                                {
                                    ti.SetValue(obj, decimal.Parse(tmpControl.Text), null);
                                }
                                else if (pt == typeof(int))
                                {
                                    ti.SetValue(obj, int.Parse(tmpControl.Text), null);
                                }
                            }
                        }
                        else if (pt == typeof(DateTime))
                        {
                            DateTime d = new DateTime();
                            if (DateTime.TryParse(tmpControl.Text, out d))
                            {
                                ti.SetValue(obj, d, null);
                            }
                        }
                    }
                    else if (i.Key is System.Web.UI.WebControls.DropDownList)
                    {
                        System.Web.UI.WebControls.DropDownList tmpControl = (System.Web.UI.WebControls.DropDownList)i.Key;
                        ti.SetValue(obj, tmpControl.SelectedValue, null);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + " Property:" + property);
            }
        }
Example #2
0
        protected override void OnInit(EventArgs e)
        {
            this.ControlStateLoaded = false;
            Page.RegisterRequiresControlState(this); // this calls LoadControlState

            if (!UseBrowseTemplate && !UseEditTemplate && !UseInlineEditTemplate && !string.IsNullOrEmpty(this.ControlPath))
            {
                var c = Page.LoadControl(this.ControlPath) as SurveyRuleUserControl;
                if (c != null)
                {
                    c.QuestionSelected += RuleControl_QuestionSelected;
                    DdlSurveyQuestions = c.FindControlRecursive("ddlSurveyQuestion") as DropDownList;

                    DataListView = c.FindControlRecursive("InnerListView") as ListView;

                    if (!this.Page.IsPostBack || SurveyRulesList == null)
                        SurveyRulesList = new List<SurveyRule>();

                    SetQuestions();
                    this.Controls.Add(c);
                }
            }

            base.OnInit(e);
        }
        protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
        {
            System.Web.UI.WebControls.DropDownList ddlGender = (System.Web.UI.WebControls.DropDownList)Grid1.Rows[e.RowIndex].FindControl("ddlGender");

            List <string> genderList = new List <string>();

            genderList.Add("男");
            genderList.Add("女");
            ddlGender.DataSource = genderList;
            ddlGender.DataBind();


            DataRowView row = e.DataItem as DataRowView;

            int gender = Convert.ToInt32(row["Gender"]);

            if (gender == 1)
            {
                ddlGender.SelectedValue = "男";
            }
            else
            {
                ddlGender.SelectedValue = "女";
            }
        }
Example #4
0
        //-------------------------------------------------------------------------------------------
        public static void PopulateListControl(MetaForeignKeyColumn Column,
            DropDownList listControl,
            Guid orgId)
        {
            //var filterAttribute = Column.GetAttribute<FilterForeignKeyAttribute>();
               //if (filterAttribute == null || Session[filterAttribute.SessionVariableName] == null)
               //{
               //     base.PopulateListControl(listControl);
               //     return;
               //}

               var context = Column.Table.CreateContext(); // get context;
               var foreignKeyTable = Column.ParentTable; // get fkTable
               var filterColumn = foreignKeyTable.GetColumn("OrganizationId"); // get filter column
               var value = orgId; //Convert.ChangeType(, filterColumn.TypeCode, System.Globalization.CultureInfo.InvariantCulture); // get value
               var query = foreignKeyTable.GetQuery(context); // Get Column Value query
               var entityParam = Expression.Parameter(foreignKeyTable.EntityType, foreignKeyTable.Name); // get the table entity to be filtered
               var property = Expression.Property(entityParam, filterColumn.Name); // get the property to be filtered
               var equalsCall = Expression.Equal(property, Expression.Constant(value)); // get the equal call
               var whereLambda = Expression.Lambda(equalsCall, entityParam); // get the where lambda
               var whereCall = Expression.Call(typeof(Queryable), "Where", new Type[] { foreignKeyTable.EntityType }, query.Expression, whereLambda); // get the where call
               var values = query.Provider.CreateQuery(whereCall);
               foreach (var row in values)
               {
                    listControl.Items.Add(new ListItem()
                    {
                         Text = foreignKeyTable.GetDisplayString(row),
                         Value = foreignKeyTable.GetPrimaryKeyString(row)
                    });
               }
        }
Example #5
0
            /// <summary>
            /// Uses a ODBCDataAdpter to create a filled array of ListItems with the given CommandText and returns a DropDownList.
            /// </summary>
            /// <param name="commandText"></param>
            /// <returns></returns>
            /// <remarks></remarks>
            public System.Web.UI.WebControls.DropDownList FilledDropDownWeb(string commandText)
            {
                var ddl = new System.Web.UI.WebControls.DropDownList();

                ddl.Items.AddRange(FilledListItemsWeb(commandText));
                return(ddl);
            }
 protected void AgregarControles(Label nombreContr, TextBox txt, DropDownList cmb, HiddenField nhf, int cont)
 {
     try
     {
         /*
         pnlSeleccionarDatos.Controls.Add(nombreContr);
         pnlSeleccionarDatos.Controls.Add(new LiteralControl(" "));
         pnlSeleccionarDatos.Controls.Add(cmb);
         pnlSeleccionarDatos.Controls.Add(new LiteralControl(" "));
         pnlSeleccionarDatos.Controls.Add(txt);
         pnlSeleccionarDatos.Controls.Add(new LiteralControl(" "));
         */
         Panel1.Controls.Add(new LiteralControl("<tr>"));
         Panel1.Controls.Add(new LiteralControl("<td>"));
         Panel1.Controls.Add(nombreContr);
         Panel1.Controls.Add(new LiteralControl("</td><td>"));
         Panel1.Controls.Add(cmb);
         Panel1.Controls.Add(new LiteralControl("</td><td>"));
         Panel1.Controls.Add(txt);
         Panel1.Controls.Add(nhf);
         Panel1.Controls.Add(new LiteralControl("</td></tr>"));
     }
     catch (Exception ex)
     {
         return;
     }
 }
 private void PopulateDropDownList(DropDownList pdlist, DataTable pDataTable, String pstrDataMember, String pstrDataValueField)
 {
     pdlist.DataSource = pDataTable;
     pdlist.DataTextField = pstrDataMember;
     pdlist.DataValueField = pstrDataValueField;
     pdlist.DataBind();
 }
Example #8
0
 public static void SetDropDownList(DataTable dataTable, System.Web.UI.WebControls.DropDownList dropDownList, string textField, string valueField)
 {
     for (int iRowCnt = 0; iRowCnt < dataTable.Rows.Count; iRowCnt++)
     {
         dropDownList.Items.Add(new ListItem(dataTable.Rows[iRowCnt][textField].ToString(), dataTable.Rows[iRowCnt][valueField].ToString()));
     }
 }
Example #9
0
        public static void SetDropDownListValue(DataTable dataTable, System.Web.UI.WebControls.DropDownList dropDownList, string selectedValue, DropDownFlag flag)
        {
            dropDownList.Items.Clear();

            if (flag == DropDownFlag.All)
            {
                dropDownList.Items.Add(new ListItem("전체선택", "0"));
            }
            else if (flag == DropDownFlag.Select)
            {
                dropDownList.Items.Add(new ListItem("선택하세요", "-1"));
            }

            for (int iRowCnt = 0; iRowCnt < dataTable.Rows.Count; iRowCnt++)
            {
                dropDownList.Items.Add(new ListItem(dataTable.Rows[iRowCnt][1].ToString(), dataTable.Rows[iRowCnt][0].ToString()));

                if (dataTable.Rows[iRowCnt][0].ToString() == selectedValue)
                {
                    if (flag == DropDownFlag.None)
                    {
                        dropDownList.SelectedIndex = iRowCnt;
                    }
                    else
                    {
                        dropDownList.SelectedIndex = iRowCnt + 1;
                    }
                }
            }
        }
Example #10
0
 public static void SetListValue(System.Web.UI.WebControls.DropDownList myListControl, object _Value)
 {
     myListControl.ClearSelection();
     if (myListControl.Items.Count == 1)
     {
         myListControl.SelectedIndex = 0;
     }
     else
     {
         if (_Value.ToString() == "0")
         {
             myListControl.SelectedIndex = 0;
         }
         else
         {
             foreach (ListItem _item in myListControl.Items)
             {
                 if (_item.Value.ToString().ToLower() == _Value.ToString().ToLower())
                 {
                     _item.Selected = true;
                     break;
                 }
             }
         }
     }
 }
Example #11
0
 public static void SetListsValue(System.Web.UI.WebControls.DropDownList myListControl, System.Web.UI.WebControls.DropDownList myListControl2, string _Value)
 {
     try
     {
         myListControl.ClearSelection();
         if (myListControl.Items.Count == 1)
         {
             myListControl.SelectedIndex  = 0;
             myListControl2.SelectedIndex = 0;
         }
         else
         {
             foreach (ListItem _item in myListControl.Items)
             {
                 if (_item.Value == _Value)
                 {
                     _item.Selected = true;
                     break;
                 }
             }
             foreach (ListItem _item in myListControl2.Items)
             {
                 if (_item.Value == _Value)
                 {
                     _item.Selected = true;
                     break;
                 }
             }
         }
     }
     catch (Exception ex)
     { var em = ex.Message; }
     finally
     { }
 }
Example #12
0
 //根据数据,生成下拉列表
 public void GetDropDownListBind(System.Web.UI.WebControls.DropDownList ddl, string strText, string strValue, string strTable, string strWhere)
 {
     ddl.DataSource     = GetList(strTable, strWhere);
     ddl.DataTextField  = strText;
     ddl.DataValueField = strValue;
     ddl.DataBind();
 }
        private void PopulateDropDowns()
        {
            Country dummy = new Country();

            dummy.CountryDescription = StaticStrings.SelectCountry;
            dummy.CountryID          = StaticStrings.CountryDummy;

            List <Country> countries = bllManagement.CountryGetAllByRole(this.Page.RadUserId());

            System.Web.UI.WebControls.DropDownList ddlCountryList = ((System.Web.UI.WebControls.DropDownList)DynamicParams.FindControl("ddlCountry"));

            ddlCountryList.DataTextField       = "CountryDescription";
            ddlCountryList.DataValueField      = "CountryID";
            ddlCountryListReset.DataTextField  = "CountryDescription";
            ddlCountryListReset.DataValueField = "CountryID";

            countries.Insert(0, dummy);

            ddlCountryList.DataSource = countries;
            ddlCountryList.DataBind();

            ddlCountryListReset.DataSource = countries;
            ddlCountryListReset.DataBind();

            if (countries.Count == 2)
            {
                ddlCountryList.SelectedIndex      = 1;
                ddlCountryListReset.SelectedIndex = 1;
            }

            ddlResetType.Items.Add(new ListItem("Utilisation", "1"));
            ddlResetType.Items.Add(new ListItem("Non/Rev", "2"));
        }
Example #14
0
        /// <summary>
        /// 控件绑定模型配置
        /// </summary>
        /// <param name="page"></param>
        /// <param name="modelName">实现IPFConfigMapper的类中定义</param>
        /// <param name="list"></param>
        public static void BindModel(string modelName, List <ModelBindConfig> list)
        {
            var modelConfig = PFDataHelper.GetMultiModelConfig(modelName);

            foreach (var i in list)
            {
                PFModelConfig config = null;
                if (modelConfig != null)
                {
                    config = modelConfig[i.GetPropertyName()];
                }
                if (i.GetComponent() is System.Web.UI.WebControls.Label)
                {
                    System.Web.UI.WebControls.Label tmpControl = (System.Web.UI.WebControls.Label)i.GetComponent();
                    LabelBind(tmpControl, config);
                }
                else if (i.GetComponent() is System.Web.UI.WebControls.TextBox)
                {
                    System.Web.UI.WebControls.TextBox tmpControl = (System.Web.UI.WebControls.TextBox)i.GetComponent();
                    BindValidator(tmpControl, config, i.GetValidator());
                    LabelBind(i.GetLabel(), config);
                    TextBoxBind(tmpControl, config);
                }
                else if (i.GetComponent() is System.Web.UI.WebControls.DropDownList)
                {
                    System.Web.UI.WebControls.DropDownList tmpControl = (System.Web.UI.WebControls.DropDownList)i.GetComponent();
                    BindValidator(tmpControl, config, i.GetValidator());
                    LabelBind(i.GetLabel(), config);
                }
            }
        }
Example #15
0
 public static void BindDate(DropDownList ddlStartYear, DropDownList ddlStartMonth, DropDownList ddlEndYear, DropDownList ddlEndMonth)
 {
     ddlStartYear.BindYear();
     ddlStartMonth.BindMonth();
     ddlEndYear.BindYear();
     ddlEndMonth.BindMonth();
 }
Example #16
0
 public static void fnAddCondition(ref System.Web.UI.WebControls.DropDownList dropDownList, ref string sSql, string sCondition)
 {
     if (dropDownList.SelectedValue.Length > 0)
     {
         sSql += " AND " + sCondition + " LIKE '" + dropDownList.SelectedValue + "' ";
     }
 }
Example #17
0
        /// <summary>
        /// Populate dropdownlist
        /// </summary>
        /// <returns></returns>
        public static void FillUpDropDown(DropDownList ddl, Hashtable ht, string defaultselectedvalue)
        {
            string strText, strValue;

            IDictionaryEnumerator ie = ht.GetEnumerator();

            while (ie.MoveNext())
            {
                ddl.Items.Add(new ListItem(ie.Value.ToString(), ie.Key.ToString()));
            }

            if (!string.IsNullOrEmpty(defaultselectedvalue))
                ddl.Items.Insert(0, new ListItem(defaultselectedvalue, "0"));

            //Loop through the items, asign text and value, and sort by text ascending.
            for (int i = ddl.Items.Count - 1; i > 0; i--)
                for (int j = 1; j < i; j++)
                {
                    if (ddl.Items[j].Text.CompareTo(ddl.Items[j + 1].Text) > 0)
                    {
                        strText = ddl.Items[j].Text;
                        strValue = ddl.Items[j].Value;
                        ddl.Items[j].Text = ddl.Items[j + 1].Text;
                        ddl.Items[j].Value = ddl.Items[j + 1].Value;
                        ddl.Items[j + 1].Text = strText;
                        ddl.Items[j + 1].Value = strValue;
                    }
                }
        }
Example #18
0
        private void FillResList(System.Web.UI.WebControls.DropDownList ddl)
        {
            ddl.Enabled = true;
            ddl.Items.Clear();

            System.Web.UI.WebControls.ListItem li = new ListItem("Select Resistance", "0");
            ddl.Items.Add(li);

            li = new ListItem("Very Resistant", "1");
            ddl.Items.Add(li);

            li = new ListItem("Resistant", "2");
            ddl.Items.Add(li);

            li = new ListItem("Moderately Resistant", "3");
            ddl.Items.Add(li);

            li = new ListItem("Moderately Susceptible", "4");
            ddl.Items.Add(li);

            li = new ListItem("Susceptible", "5");
            ddl.Items.Add(li);

            li = new ListItem("Very Susceptible", "6");
            ddl.Items.Add(li);
        }
Example #19
0
 public static void FillCombo(this System.Web.UI.WebControls.DropDownList ddl, DropDownName dname, string Condition = "")
 {
     try
     {
         List <clsDropDown> ddllist = new List <clsDropDown>();
         using (var client = new HttpClient())
         {
             //client.BaseAddress = new Uri(ConfigurationManager.AppSettings["WebApiUrl"].ToString());
             client.BaseAddress = new Uri(System.Web.HttpContext.Current.Session["WebApiUrl"].ToString());
             client.DefaultRequestHeaders.Accept.Clear();
             client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
             HttpResponseMessage response = client.GetAsync(string.Format("api/DropDownData/{0}?&param1={1}", dname.ToString(), Condition)).Result;
             //response.Content.ReadAsStringAsync().Result
             if (response.IsSuccessStatusCode && !string.IsNullOrEmpty(response.Content.ReadAsStringAsync().Result))
             {
                 System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                 ddllist = serializer.Deserialize <List <clsDropDown> >(response.Content.ReadAsStringAsync().Result);
             }
         }
         ddl.DataSource     = ddllist;
         ddl.DataTextField  = "DisplayField";
         ddl.DataValueField = "ValueField";
         ddl.DataBind();
         ddl.Items.Insert(0, new ListItem("--Select--", System.Convert.ToString(0)));
     }
     catch (Exception ex)
     { }
 }
Example #20
0
        private void FillDecisionQueries(System.Web.UI.WebControls.DropDownList ddl, string northSouth)
        {
            ddl.Enabled = true;
            ddl.Items.Clear();

            System.Web.UI.WebControls.ListItem li = new ListItem("Select a question", "any");
            ddl.Items.Add(li);

            li = new ListItem("Aphanomyces resistance of at least:", "aphanomyces");
            ddl.Items.Add(li);

            li = new ListItem("Nematode resistance of at least:", "nematode");
            ddl.Items.Add(li);

            li = new ListItem("Curly Top resistance of at least:", "curlytop");
            ddl.Items.Add(li);

            li = new ListItem("Fusarium resistance of at least:", "fusarium");
            ddl.Items.Add(li);

            li = new ListItem("Root Aphid resistance of at least:", "rootaphid");
            ddl.Items.Add(li);

            li = new ListItem("Cercospora resistance of at least:", "cercospora");
            ddl.Items.Add(li);

            li = new ListItem("Rhizoctonia resistance of at least:", "rhizoctonia");
            ddl.Items.Add(li);
        }
Example #21
0
    //DropDownList
    // 'dropdwonlist 綁定
    public void  Dropdownlist_Bind(System.Web.UI.WebControls.DropDownList ddr, DataTable dt, string value, string text, int type)
    {
        ddr.Items.Clear();
        if (type == 1)
        {
            ddr.Items.Add("");
        }

        if (dt.Rows.Count == 0)
        {
            return;
        }

        //  string msg  = "";
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            ListItem item = new ListItem();

            item.Value = "";
            if (!(dt.Rows[i][value] is DBNull))
            {
                item.Value = dt.Rows[i][value].ToString().Trim();
            }

            item.Text = "";
            if (!(dt.Rows[i][text] is DBNull))
            {
                item.Text = item.Value + "--" + dt.Rows[i][text].ToString().Trim();
            }

            ddr.Items.Add(item);
        }
    }
Example #22
0
 private void SetDropDownListMonth(System.Web.UI.WebControls.DropDownList ddlMonth)
 {
     for (int i = 1; i <= 12; i++)
     {
         ddlMonth.Items.Add(new ListItem(i.ToString().PadLeft(2, '0'), i.ToString().PadLeft(2, '0')));
     }
 }
Example #23
0
        protected override void CreateChildControls()
        {
            this.Title = "Custom Medalsoft properties";

            txtTitle = new TextBox();
            txtTitle.Width = new Unit("100%");

            ddlWebpartType = new DropDownList();
            ddlWebpartType.ID = "ddlWebpartType";
            ddlWebpartType.Items.Add(new ListItem("News", WebPartType.News));
            ddlWebpartType.Items.Add(new ListItem("Announcement", WebPartType.Announcement));
            ddlWebpartType.SelectedIndexChanged += new EventHandler(ddlWebpartType_SelectedIndexChanged);
            ddlWebpartType.AutoPostBack = true;

            txtPageSize = new TextBox();
            txtPageSize.Width = new Unit("20%");

            tvNewsType = GenerateTreeViewForNewsType();

            Controls.Add(new LiteralControl("<div class='MedalsoftEditorDiv'>Type a webpart title:</div>"));
            Controls.Add(txtTitle);
            Controls.Add(new LiteralControl("<div class='MedalsoftEditorDiv'>Select webpart type:</div>"));
            Controls.Add(ddlWebpartType);
            Controls.Add(new LiteralControl("<div class='MedalsoftEditorDiv'>Type a page size:</div>"));
            Controls.Add(txtPageSize);
            LiteralControl lcNewsType = new LiteralControl("<div class='MedalsoftEditorDiv'>Select displaying News Type:</div>");
            lcNewsType.ID = "lcNewsType";
            Controls.Add(lcNewsType);
            Controls.Add(tvNewsType);
        }
Example #24
0
        /// <summary>
        /// Generates the HTML markup for the Numeric Pages button bar
        /// </summary>
        /// <param name="cell"></param>
        private void BuildNumericPagesUI(TableCell cell)
        {
            // Render a drop-down list
            System.Web.UI.WebControls.DropDownList pageList = new System.Web.UI.WebControls.DropDownList();
            pageList.ID                    = "PageList";
            pageList.AutoPostBack          = true;
            pageList.SelectedIndexChanged += new EventHandler(PageList_Click);
            pageList.Font.Name             = Font.Name;
            pageList.Font.Size             = Font.Size;
            pageList.ForeColor             = ForeColor;

            // Embellish the list when there are no pages to list
            if (PageCount <= 0 || PageIndex == -1)
            {
                pageList.Items.Add("No pages");
                pageList.Enabled       = false;
                pageList.SelectedIndex = 0;
            }
            else // Populate the list
            {
                for (int i = 1; i <= PageCount; i++)
                {
                    ListItem item = new ListItem(i.ToString(), (i - 1).ToString());
                    pageList.Items.Add(item);
                }
                pageList.SelectedIndex = PageIndex;
            }
            cell.Controls.Add(pageList);
        }
Example #25
0
        // //识别是F5刷新还是点击按钮提交
        // private static string MaskKey = "____MASKKEY"; //注册全局的MaskKey

        // private void InitialMask()
        // {
        //     this.Session[MaskKey] = this.ViewState[MaskKey] = Guid.NewGuid().ToString();//重新发号 给Session 和 ViewState 新的Guid Session在服务器端标志 ViewState放在客户端标志
        // }
        // protected override void OnPreRender(EventArgs e)
        // {
        //     base.OnPreRender(e);
        //     InitialMask();//发号
        // }
        // public bool IsRefresh
        // {
        //     get
        //     {
        //         if (this.Session[MaskKey] == null || this.ViewState[MaskKey] == null) return false;
        //         return !this.Session[MaskKey].ToString().Equals(this.ViewState[MaskKey].ToString());//检查Key是否相同
        //     }
        // }
        // //protected void btnTest_Click(object sender, EventArgs e)
        // //{
        // //    this.lblGuid.Text = this.Session[MaskKey].ToString() + " " + this.ViewState[MaskKey].ToString();//打印Key
        // //}
        // //private void ShowStatus()
        // //{
        // //    if (this.IsRefresh)
        // //    {
        // //        this.lblShow.Text = "F5 Refresh";
        // //    }
        // //    else
        // //    {
        // //        this.lblShow.Text = "Html Dom submit";
        // //    }
        // //}
        ////////////////////////////////////////////////////////////////////////////////


        /// <summary>
        /// Bind Data DropDown
        /// </summary>
        /// <param name="ddl"></param>
        /// <param name="dataList"></param>
        /// <param name="isALL"></param>
        public void DropDownListDataBind(System.Web.UI.WebControls.DropDownList ddl, IList <string> dataList, bool isEmpty)
        {
            if (ddl == null)
            {
                throw new ArgumentNullException("ddl");
            }

            ddl.Items.Clear();

            if (isEmpty)
            {
                ddl.Items.Add("");
            }

            if (dataList.Count > 0)
            {
                foreach (string data in dataList)
                {
                    if (!string.IsNullOrEmpty(data))
                    {
                        ddl.Items.Add(data.Trim());
                    }
                }
            }
        }
Example #26
0
 /// <summary>
 /// 绑定下拉列表(数据显示控件或者源数据集不存在都会引发异常)
 /// </summary>
 /// <param name="ddl">数据显示控件</param>
 /// <param name="ds">数据集</param>
 /// <param name="DataTextField">文本数据源</param>
 /// <param name="DataValueField">值数据源</param>
 /// <param name="hasTopItem">bool,是否有默认第一项</param>
 /// <param name="topItemText">第一项文本</param>
 /// <param name="topItemValue">第一项值</param>
 public static void Bind(System.Web.UI.WebControls.DropDownList ddl, DataSet ds, string DataTextField, string DataValueField, bool hasTopItem, string topItemText, string topItemValue)
 {
     if (ddl != null)
     {
         if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
         {
             ddl.ClearSelection();
             ddl.Items.Clear();
             ddl.DataTextField  = DataTextField;
             ddl.DataValueField = DataValueField;
             ddl.DataSource     = ds.Tables[0].DefaultView;
             ddl.DataBind();
             if (hasTopItem)
             {
                 ListItem lit = new ListItem(topItemText, topItemValue);
                 ddl.Items.Insert(0, lit);
             }
         }
         else
         {
             throw new Exception("源数据集不存在");
         }
     }
     else
     {
         throw new Exception("数据控件不存在");
     }
 }
Example #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            uToolsCore.Authorize();

            DropDownList ddl = new DropDownList();
            ddl.CssClass = "logType";

            //log types
            ddl.Items.Add(new ListItem("All",""));
            foreach (var logType in Enum.GetValues(typeof(LogTypes)).Cast<LogTypes>())
            {
                ddl.Items.Add(new ListItem(logType.ToString(), Convert.ToInt32(logType).ToString()));
            }
            logTypes.Controls.Add(ddl);

            ddl = new DropDownList();
            ddl.Items.Add(new ListItem("All", ""));
            ddl.CssClass = "userName";

            foreach (User thisUser in umbraco.BusinessLogic.User.getAll())
            {
                ddl.Items.Add(new ListItem(thisUser.LoginName, thisUser.Id.ToString()));
            }
            userName.Controls.Add(ddl);
        }
 public void OnSelChangeSelectMode(object sender, System.EventArgs e)
 {
     System.Web.UI.WebControls.DropDownList dropdown = (System.Web.UI.WebControls.DropDownList)sender;
     Session["TableSelectMode"] = dropdown.SelectedItem.Text;
     lblError.Text = "";
     ReBind();
 }
Example #29
0
        public void RenderAsControl(Option baseOption, PlaceHolder ph, string prefix = null)
        {
            var result = new System.Web.UI.WebControls.DropDownList();

            result.ID           = "opt" + prefix + baseOption.Bvin.Replace("-", string.Empty);
            result.ClientIDMode = ClientIDMode.Static;
            result.CssClass     = "hcIsOption";

            foreach (var o in baseOption.Items)
            {
                var li = new ListItem();
                li.Text = o.Name;

                if (o.IsLabel)
                {
                    li.Value   = string.Empty;
                    li.Enabled = false;
                }
                else
                {
                    li.Value = o.Bvin.Replace("-", string.Empty);
                }
                if (o.IsDefault)
                {
                    li.Selected = true;
                }
                result.Items.Add(li);
            }

            ph.Controls.Add(result);
        }
Example #30
0
 public void FillCmb(String str, Object ItemArray, string FirstR, System.Web.UI.WebControls.DropDownList DropDownName)
 {
     try
     {
         if (con.State == ConnectionState.Closed)
         {
             con.Open();
         }
         DataTable dt = new DataTable();
         dt.Clear();
         DataRow        drow;
         SqlDataAdapter da = new SqlDataAdapter(str, con);
         da.Fill(dt);
         drow           = dt.NewRow();
         drow.ItemArray = new object[] { FirstR, 0 };
         dt.Rows.InsertAt(drow, 0);
         DropDownName.DataSource     = dt;
         DropDownName.DataValueField = dt.Columns[1].ToString();
         DropDownName.DataTextField  = dt.Columns[0].ToString();
         DropDownName.DataBind();
         con.Close();
     }
     catch (Exception ex)
     {
         // MessageBox.Show(ex.Message);
     }
 }
Example #31
0
 public Estado(DropDownList ddl)
 {
     ddl.Items.Clear();
     ddl.Items.Add("");
     ddl.Items.Add(new ListItem("Acre", "AC"));
     ddl.Items.Add(new ListItem("Alagoas", "AL"));
     ddl.Items.Add(new ListItem("Amapá", "AP"));
     ddl.Items.Add(new ListItem("Amazonas", "AM"));
     ddl.Items.Add(new ListItem("Bahia", "BA"));
     ddl.Items.Add(new ListItem("Ceará", "CE"));
     ddl.Items.Add(new ListItem("Distrito Federal", "DF"));
     ddl.Items.Add(new ListItem("Espírito Santo", "ES"));
     ddl.Items.Add(new ListItem("Goiás", "GO"));
     ddl.Items.Add(new ListItem("Maranhão", "MA"));
     ddl.Items.Add(new ListItem("Mato Grosso", "MT"));
     ddl.Items.Add(new ListItem("Mato Grosso do Sul", "MS"));
     ddl.Items.Add(new ListItem("Minas Gerais", "MG"));
     ddl.Items.Add(new ListItem("Pará", "PA"));
     ddl.Items.Add(new ListItem("Paraíba", "PB"));
     ddl.Items.Add(new ListItem("Paraná", "PR"));
     ddl.Items.Add(new ListItem("Pernambuco", "PE"));
     ddl.Items.Add(new ListItem("Piauí", "PI"));
     ddl.Items.Add(new ListItem("Rio de Janeiro", "RJ"));
     ddl.Items.Add(new ListItem("Rio Grande do Norte", "RN"));
     ddl.Items.Add(new ListItem("Rio Grando do Sul", "RS"));
     ddl.Items.Add(new ListItem("Rondônia", "RO"));
     ddl.Items.Add(new ListItem("Rorâima", "RR"));
     ddl.Items.Add(new ListItem("Santa Catarina", "SC"));
     ddl.Items.Add(new ListItem("São Paulo", "SP"));
     ddl.Items.Add(new ListItem("Sergipe", "SE"));
     ddl.Items.Add(new ListItem("Tocantins", "TO"));
 }
        /// <summary>
        /// Binds A Control That Is Past To It With A Portals Roles
        /// </summary>
        /// <param name="dropDown"></param>
        /// <param name="addNoRoles"></param>
        private void BindRoleData(System.Web.UI.WebControls.DropDownList dropDown, bool addNoRoles)
        {
            // Get the portal's roles from the database

            System.Data.SqlClient.SqlDataReader roleDataReader = users.GetPortalRoles(portalSettings.PortalID);

            dropDown.DataSource     = roleDataReader;
            dropDown.DataTextField  = "RoleName";
            dropDown.DataValueField = "RoleID";
            dropDown.DataBind();
            if (addNoRoles)
            {
                dropDown.Items.Add("Not In Any Role");
            }

            roleDataReader.Close();

            if (PortalSecurity.IsInRoles("Admins") == false)
            {
                // Added by Mario Endara <*****@*****.**> 2004/11/04
                // if the user is not member of the "Admins" role, remove it from the dropdownlist
                if (dropDown.Items.FindByText("Admins") != null)
                {
                    dropDown.Items.Remove(dropDown.Items.FindByText("Admins"));
                }
            }
        }
        public static void BindCombo(
            ref DropDownList Cbo
            , DataTable Dt
            , string Value
            , string Text
            , object Default_Value
            , string Default_Text
            )
        {
            DataTable Dt_Bind = Dt.Clone();
            DataRow Dr = Dt_Bind.NewRow();
            Dr[Value] = Default_Value;
            Dr[Text] = Default_Text;
            Dt_Bind.Rows.Add(Dr);

            foreach( DataRow Inner_Dr  in Dt.Rows)
            {
                DataRow Nr = Dt_Bind.NewRow();
                Nr[Value] = Inner_Dr[Value];
                Nr[Text] = Inner_Dr[Text];
                Dt_Bind.Rows.Add(Nr);
            }

            BindCombo(ref Cbo, Dt_Bind, Value, Text);
        }
Example #34
0
 private void SetDropDownListYear(System.Web.UI.WebControls.DropDownList ddlYear)
 {
     for (int i = System.DateTime.Now.Year; i >= 1999; i--)
     {
         ddlYear.Items.Add(new ListItem(i.ToString(), i.ToString()));
     }
 }
Example #35
0
        /// <summary>
        /// 绑定生成一个有树结构的下拉菜单
        /// </summary>
        /// <param name="dtNodeSets">菜单记录数据所在的表</param>
        /// <param name="strParentColumn">表中用于标记父记录的字段</param>
        /// <param name="strRootValue">第一层记录的父记录值(通常设计为0或者-1或者Null)用来表示没有父记录</param>
        /// <param name="strIndexColumn">索引字段,也就是放在DropDownList的Value里面的字段</param>
        /// <param name="strTextColumn">显示文本字段,也就是放在DropDownList的Text里面的字段</param>
        /// <param name="drpBind">需要绑定的DropDownList</param>
        /// <param name="i">用来控制缩入量的值,请输入-1</param>
        public static void MakeTree(DataTable dtNodeSets, string strParentColumn, string strRootValue, string strIndexColumn, string strTextColumn, DropDownList drpBind, int i)
        {
            //每向下一层,多一个缩入单位
            i++;

            DataView dvNodeSets = new DataView(dtNodeSets);
            dvNodeSets.RowFilter = strParentColumn + "=" + strRootValue;

            string strPading = "";  //缩入字符

            //通过i来控制缩入字符的长度,我这里设定的是一个全角的空格
            for (int j = 0; j < i; j++)
                strPading += " ";//如果要增加缩入的长度,改成两个全角的空格就可以了

            foreach (DataRowView drv in dvNodeSets)
            {
                TreeNode tnNode = new TreeNode();
                ListItem li = new ListItem(strPading + "├" + drv[strTextColumn].ToString(), drv[strIndexColumn].ToString());
                drpBind.Items.Add(li);
                MakeTree(dtNodeSets, strParentColumn, drv[strIndexColumn].ToString(), strIndexColumn, strTextColumn, drpBind, i);
            }

            //递归结束,要回到上一层,所以缩入量减少一个单位
            i--;
        }
        // populate vat dropdown list
        public static void PopulateVATDropdownList(ref DropDownList ddlVAT, System.Web.SessionState.HttpSessionState currentSession)
        {
            try
            {
                // if session already contains the list items then no need to execute loop and items
                if (currentSession["VATListItems"] != null)
                {
                    // extract items from session
                    ddlVAT.Items.AddRange(((ListItemCollection)currentSession["VATListItems"]).Cast<System.Web.UI.WebControls.ListItem>().ToArray());
                }
                else
                {
                    // creating items for VAT %age from 1 to 20 with decimal places 1 to 9, in this way we will have items like (e.g 1%, 1.1%, 1.2%.........19.9%, 20%)
                    // outer look for 1 to 20 items
                    for (int i = 0; i < 20; i++)
                    {
                        // inner loop to create decimal items 1 to 9 for each outer loop value
                        for (int j = 0; j < 10; j++)
                        {
                            // NOTE: (j == 0 ? "" : "." + j.ToString()) skip and allow to add start value
                            ddlVAT.Items.Add(new ListItem(i.ToString() + (j == 0 ? "" : "." + j.ToString()) + "%", i.ToString() + (j == 0 ? "" : "." + j.ToString())));
                        }
                    }
                    // adding last item as loops created max 19.9% item
                    ddlVAT.Items.Add(new ListItem("20%", "20"));

                    // adding list items to session, caching it to re-use
                    currentSession["VATListItems"] = ddlVAT.Items;
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Label lblQuestion = new Label();
            _ddAnswer = new DropDownList();
            RequiredFieldValidator valQuestion = new RequiredFieldValidator();

            lblQuestion.ID = "lbl" + _question.QuestionGuid.ToString().Replace("-", String.Empty);
            _ddAnswer.ID = "dd" + _question.QuestionGuid.ToString().Replace("-", String.Empty);
            valQuestion.ID = "val" + _question.QuestionGuid.ToString().Replace("-", String.Empty);

            lblQuestion.Text = _question.QuestionText;
            lblQuestion.AssociatedControlID = _ddAnswer.ID;

            valQuestion.ControlToValidate = _ddAnswer.ID;
            valQuestion.Enabled = _question.AnswerIsRequired;

            _ddAnswer.Items.Add(new ListItem(Resources.SurveyResources.DropDownPleaseSelectText, String.Empty));

            foreach (QuestionOption option in _options)
            {
                ListItem li = new ListItem(option.Answer);
                if (li.Value == _answer) li.Selected = true;
                _ddAnswer.Items.Add(li);
            }

            valQuestion.Text = _question.ValidationMessage;

            Controls.Add(lblQuestion);
            Controls.Add(_ddAnswer);
            Controls.Add(valQuestion);
        }
Example #38
0
 protected override void InitializeDataCell(DataControlFieldCell cell, DataControlRowState rowState)
 {
     DropDownList ddl = new DropDownList();
     ddl.Items.Add("");
     ddl.AppendDataBoundItems = true;
     if (!string.IsNullOrEmpty(this.DataSourceID) || null != this.DataSource)
     {
         if (!string.IsNullOrEmpty(this.DataSourceID))
         {
             ddl.DataSourceID = this.DataSourceID;
         }
         else
         {
             ddl.DataSource = this.DataSource;
         }
         ddl.DataTextField = this.DataTextField;
         ddl.DataValueField = this.DataValueField;
     }
     if (this.DataField.Length != 0)
     {
         ddl.DataBound += new EventHandler(this.OnDataBindField);
     }
     ddl.Enabled = false;
     if ((rowState & DataControlRowState.Edit) != DataControlRowState.Normal || (rowState & DataControlRowState.Insert) != DataControlRowState.Normal)
     {
         ddl.Enabled = true;
     }
     cell.Controls.Add(ddl);
 }
 protected internal override void CreateChildControls()
 {
     ControlCollection controls = this.Controls;
     controls.Clear();
     TypeConverter converter = TypeDescriptor.GetConverter(typeof(PartChromeState));
     this._chromeState = new DropDownList();
     this._chromeState.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeState_Normal"), converter.ConvertToString(PartChromeState.Normal)));
     this._chromeState.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeState_Minimized"), converter.ConvertToString(PartChromeState.Minimized)));
     controls.Add(this._chromeState);
     this._zone = new DropDownList();
     WebPartManager webPartManager = base.WebPartManager;
     if (webPartManager != null)
     {
         WebPartZoneCollection zones = webPartManager.Zones;
         if (zones != null)
         {
             foreach (WebPartZoneBase base2 in zones)
             {
                 ListItem item = new ListItem(base2.DisplayTitle, base2.ID);
                 this._zone.Items.Add(item);
             }
         }
     }
     controls.Add(this._zone);
     this._zoneIndex = new TextBox();
     this._zoneIndex.Columns = 10;
     controls.Add(this._zoneIndex);
     foreach (Control control in controls)
     {
         control.EnableViewState = false;
     }
 }
Example #40
0
        protected override void InitializeSkin(System.Web.UI.Control Skin)
        {
            KeyWords=(TextBox)Skin.FindControl("KeyWords");
            AllowPsd = (CheckBox)Skin.FindControl("AllowPsd");
            IsEnReply = (CheckBox)Skin.FindControl("IsEnReply");
            IsIndexShow = (CheckBox)Skin.FindControl("IsIndexShow");
            AllowPsd.Attributes.Add("onclick", "AllowPsd()");
            TextBox1 = (TextBox)Skin.FindControl("TextBox1");
            TextBox2 = (TextBox)Skin.FindControl("TextBox2");  //js把logId写入

            CreateTime = (TextBox)Skin.FindControl("CreateTime");
            if (!Page.IsPostBack)
            {
                CreateTime.Text = DateTime.Now.ToString();
            }

            LogIdTex = (TextBox)Skin.FindControl("LogId");//没有用到啊···
            Title = (TextBox)Skin.FindControl("title");
            Add = (Button)Skin.FindControl("Add");
            AddDraft = (Button)Skin.FindControl("AddDraft");
            Cansel = (Button)Skin.FindControl("Cansel");
            Editor = (TextBox)Skin.FindControl("txtContent");
            LogCategory = (DropDownList)Skin.FindControl("LogCategory");
            this.DataBind();
        }
        public static void load_data_to_cbo_bo_tinh(
            eTAT_CA ip_e_tat_ca
            , DropDownList ip_obj_cbo_bo_tinh)
        {
            US_DM_DON_VI v_us_dm_don_vi = new US_DM_DON_VI();
            DS_DM_DON_VI v_ds_dm_don_vi = new DS_DM_DON_VI();

            //v_us_dm_don_vi.FillDataset(v_ds_dm_don_vi, "where ID_LOAI_DON_VI = " + ID_LOAI_DON_VI.BO_TINH);
            string v_str_user_name = HttpContext.Current.Session[SESSION.UserName].ToString();
            v_us_dm_don_vi.FillDataset(
                v_ds_dm_don_vi
                , ID_LOAI_DON_VI.BO_TINH

                , CONST_QLDB.ID_TAT_CA
                , CONST_QLDB.ID_TAT_CA
                , v_str_user_name);

            ip_obj_cbo_bo_tinh.DataSource = v_ds_dm_don_vi.DM_DON_VI;
            ip_obj_cbo_bo_tinh.DataTextField = DM_DON_VI.TEN_DON_VI;
            ip_obj_cbo_bo_tinh.DataValueField = DM_DON_VI.ID;
            ip_obj_cbo_bo_tinh.DataBind();
            if (ip_e_tat_ca == eTAT_CA.YES)
            {
                ip_obj_cbo_bo_tinh.Items.Insert(0, new ListItem(CONST_QLDB.TAT_CA, CONST_QLDB.ID_TAT_CA.ToString()));
            }
        }
Example #42
0
        private bool completarCampos(string idiomaID, string rut)
        {
            int i = System.Convert.ToInt32(idiomaID);

            idiomaID = i.ToString();
            string sql = "SELECT * FROM " + tabla + "idiomas WHERE idiomaID = '" + idiomaID + "' AND rut = '" + rut + "';";

            System.DateTime dateTime = System.DateTime.Now;
            Trace.Write(dateTime.ToString() + " OK/EGRESADOidiomas / CompletarCampos");
            System.Data.SqlClient.SqlConnection adoConn = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["BaseSqlServer"].ConnectionString);
            adoConn.Open();
            System.Data.SqlClient.SqlCommand adoCmd = new System.Data.SqlClient.SqlCommand(sql, adoConn);
            Trace.Write(sql);
            System.Data.SqlClient.SqlDataReader dr = adoCmd.ExecuteReader();
            if (dr.Read())
            {
                this.idiomaID.DataBind();
                oral.DataBind();
                escrito.DataBind();
                this.idiomaID.SelectedIndex = this.idiomaID.Items.IndexOf(this.idiomaID.Items.FindByValue(dr["idiomaID"].ToString()));
                oral.SelectedIndex          = oral.Items.IndexOf(oral.Items.FindByValue(dr["oral"].ToString()));
                escrito.SelectedIndex       = escrito.Items.IndexOf(escrito.Items.FindByValue(dr["escrito"].ToString()));
                this.idiomaID.Enabled       = false;
            }
            else
            {
                return(false);
            }
            return(true);
        }
        protected override void CreateChildControls()
        {
            var config = (TfsConfigurer)this.GetExtensionConfigurer();

            this.txtArtifactName = new ValidatingTextBox { DefaultText = "Same as project name" };
            this.txtTeamProject = new TeamProjectPicker(config);
            this.txtBuildDefinition = new BuildDefinitionPicker(config);
            this.txtTeamProject.SelectedIndexChanged += (s, e) => { this.txtBuildDefinition.TeamProject = this.txtTeamProject.SelectedValue; };
            this.ddlBuildNumber = new DropDownList
            {
                Items =
                {
                    new ListItem("allow selection at build time", string.Empty),
                    new ListItem("last succeeded build", "success"),
                    new ListItem("last completed build", "last")
                }
            };
            this.txtBuildNumberPattern = new ValidatingTextBox { Text = "_(?<num>[^_]+)$" };

            this.Controls.Add(
                new SlimFormField("Artifact name:", this.txtArtifactName),
                new SlimFormField("Team project:", this.txtTeamProject),
                new SlimFormField("Build definition:", txtBuildDefinition),
                new SlimFormField("Build number:", this.ddlBuildNumber),
                new SlimFormField("Capture pattern:", this.txtBuildNumberPattern)
                {
                    HelpText = "When importing a build, you can opt to use the TFS build number; however, because TFS build numbers "
                    + "can be 1,000 characters (or more), up to 10 characters must be extracted to fit the BuildMaster build number "
                    + "using a Regex capture group named \"num\". The default TFS Build Number Format is $(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r); "
                    + " and thus the pattern _(?<num>[^_]+)$ will extract the date and revision."
                }
            );
        }
Example #44
0
        public static void selDropDownList(System.Web.UI.WebControls.DropDownList obj, string config, string sql, string firstString, string addnew)
        {
            string         ConnStr = ConfigurationManager.AppSettings[config];
            SqlConnection  cn      = new SqlConnection(ConnStr);
            SqlDataAdapter da      = new SqlDataAdapter(sql, cn);

            DataSet ds = new DataSet();

            da.Fill(ds, "dropdownlist");

            obj.DataSource     = ds.Tables["dropdownlist"].DefaultView;
            obj.DataValueField = ds.Tables["dropdownlist"].Columns[0].ToString();
            obj.DataTextField  = ds.Tables["dropdownlist"].Columns[1].ToString();
            obj.DataBind();

            if (obj.Items.Count == 0)
            {
                obj.Items.Insert(0, new ListItem("-- no data found --", Constant.DefaultSelect));
            }
            else
            {
                obj.Items.Insert(0, addnew);
                obj.Items.Insert(0, firstString);
            }
        }
 private void ChangeVisible(int index, DropDownList dropDownList, TextBox txtBox)
 {
     if (index == 1)
         dropDownList.Style["visibility"] = "visible";
     if(index == 2)
         txtBox.Style["visibility"] = "visible";
 }
		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			_dlShippingProviderTypes = new DropDownList();

			var shippingProviderTypePickupText = library.GetDictionaryItem("ShippingProviderTypePickup");
			if (string.IsNullOrEmpty(shippingProviderTypePickupText))
			{
				shippingProviderTypePickupText = "Pickup";
			}

			var shippingProviderTypeShippingText = library.GetDictionaryItem("ShippingProviderTypeShipping");
			if (string.IsNullOrEmpty(shippingProviderTypeShippingText))
			{
				shippingProviderTypeShippingText = "Shipping";
			}

			_dlShippingProviderTypes.Items.Add(new ListItem(shippingProviderTypePickupText, Common.ShippingProviderType.Pickup.ToString()));
			_dlShippingProviderTypes.Items.Add(new ListItem(shippingProviderTypeShippingText, Common.ShippingProviderType.Shipping.ToString()));

			_dlShippingProviderTypes.SelectedValue = _data.Value.ToString();

			if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_dlShippingProviderTypes);
		}
Example #47
0
 public void Fillddl_noselect(DropDownList ddl, DataTable mydt, string textField, string valueFeild)
 {
     ddl.DataSource = mydt;
     ddl.DataValueField = valueFeild;
     ddl.DataTextField = textField;
     ddl.DataBind();
 }
		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			_dlInstalledStores = new DropDownList();

			var chooseText = library.GetDictionaryItem("Choose");
			if (string.IsNullOrEmpty(chooseText))
			{
				chooseText = "Choose...";
			}

			_dlInstalledStores.Items.Add(new ListItem(chooseText, "0"));

			foreach (var store in StoreHelper.GetAllStores())
			{
				_dlInstalledStores.Items.Add(new ListItem(store.Alias, store.Id.ToString()));
			}

			if (_data.Value != null)
			{
				try
				{
					_dlInstalledStores.SelectedValue = _data.Value.ToString();
				}
				catch
				{
				}
			}

			if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_dlInstalledStores);
		}
		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			_dlPaymentProviderTypes = new DropDownList();

			var paymentProviderAmountTypeAmountText = library.GetDictionaryItem("PaymentProviderAmountTypeAmount");
			if (string.IsNullOrEmpty(paymentProviderAmountTypeAmountText))
			{
				paymentProviderAmountTypeAmountText = "Amount";
			}

			var paymentProviderAmountTypeOrderPercentageText = library.GetDictionaryItem("PaymentProviderAmountTypeOrderPercentage");
			if (string.IsNullOrEmpty(paymentProviderAmountTypeOrderPercentageText))
			{
				paymentProviderAmountTypeOrderPercentageText = "Percentage of order total";
			}

			_dlPaymentProviderTypes.Items.Add(new ListItem(paymentProviderAmountTypeAmountText, Common.PaymentProviderAmountType.Amount.ToString()));
			_dlPaymentProviderTypes.Items.Add(new ListItem(paymentProviderAmountTypeOrderPercentageText, Common.PaymentProviderAmountType.OrderPercentage.ToString()));

			_dlPaymentProviderTypes.SelectedValue = _data.Value.ToString();

			var user = User.GetCurrent();

			if (!user.IsAdmin())
			{
				_dlPaymentProviderTypes.Enabled = false;
			}

			if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_dlPaymentProviderTypes);
		}
Example #50
0
        /// <summary>
        /// 使用字碼主檔記錄綁定指定的下拉框的數據源的中文描述值
        /// </summary>
        /// <param name="ddlTarget">指定的下拉框控件</param>
        /// <param name="listCMT_MacType">字碼主檔記錄</param>
        /// <param name="idxEmptyItem">空值項的序號(小於0時不作添加)</param>
        public static void BindListItems_CodeMasterInfos_OnlyDesc(DropDownList ddlTarget, List<CodeMaster_cmt_Info> listCodeMaster, int idxEmptyItem)
        {
            if (ddlTarget == null)
            {
                return;
            }

            ddlTarget.Items.Clear();

            if (listCodeMaster != null && listCodeMaster.Count > 0)
            {
                for (int i = 0; i < listCodeMaster.Count; i++)
                {
                    if (idxEmptyItem == i)
                    {
                        AddDropDownListEmptyItem(ddlTarget);
                    }

                    ListItem itemType = new ListItem();
                    itemType.Text = listCodeMaster[i].cmt_cRemark;
                    itemType.Value = listCodeMaster[i].cmt_cRemark;
                    ddlTarget.Items.Add(itemType);
                }
            }
        }
Example #51
0
 protected void BindDDL(DropDownList ddl,Dictionary<string,string> dict)
 {
     ddl.DataSource = dict;
     ddl.DataTextField = "Value";
     ddl.DataValueField = "Key";
     ddl.DataBind();
 }
Example #52
0
        public static void BuildStudentProspectTable(Table table, string userId)
        {
            GroupService service = new GroupService();
            DataTable dtProspects = service.GetProspectiveStudentsData(userId);
            DataTable dtGroups = service.GetSupervisorOfData(userId);

            for (int i = 0; i < dtProspects.Rows.Count; i++)
            {
                DropDownList ddlGroupList = new DropDownList();
                ddlGroupList.DataSource = dtGroups;
                ddlGroupList.DataTextField = "GroupName";
                ddlGroupList.DataValueField = "GroupId";
                ddlGroupList.DataBind();
                ddlGroupList.Items.Insert(0, "Add a group");

                string name = dtProspects.Rows[i].ItemArray[0].ToString();
                string id = dtProspects.Rows[i].ItemArray[1].ToString();

                LinkButton b = new LinkButton();
                b.Text = name;
                b.CommandArgument = id;
                b.CommandName = name;

                TableRow row = new TableRow();
                TableCell cellProspects = new TableCell();
                TableCell cellGroups = new TableCell();

                cellProspects.Controls.Add(b);
                cellGroups.Controls.Add(ddlGroupList);
                row.Cells.Add(cellProspects);
                row.Cells.Add(cellGroups);
                table.Rows.Add(row);
            }
        }
        private void PopulateDropDowns()
        {
            Country dummy = new Country();

            dummy.CountryDescription = StaticStrings.SelectCountry;
            dummy.CountryID          = StaticStrings.CountryDummy;

            List <Country> countries       = bllParams.CountryGetAll();
            List <Country> accessCountries = new List <Country>();

            foreach (Country country in countries)
            {
                if (roles.Exists(r => (r.RoleCountry == country.CountryID) &&
                                 ((RoleCodes)r.RoleID == RoleCodes.TDAdjustmentAndReconciliation)))
                {
                    accessCountries.Add(country);
                }
            }


            System.Web.UI.WebControls.DropDownList ddlCountryList = ((System.Web.UI.WebControls.DropDownList)dpForecastReconciliation.FindControl("ddlCountry"));
            ddlCountryList.DataTextField  = "CountryDescription";
            ddlCountryList.DataValueField = "CountryID";
            accessCountries.Insert(0, dummy);
            ddlCountryList.DataSource = accessCountries;
            ddlCountryList.DataBind();

            if (accessCountries.Count == 2)
            {
                ddlCountryList.SelectedIndex = 1;
            }
        }
 /// <summary>
 /// Fills dropdownlist list with data from dataSource     
 /// <param name="list"></param>
 /// <param name="dataSource"></param>
 /// <param name="needEmpty">Indicates if we have to add empty element to dropDownList</param>
 /// <param name="dataValueField">value</param>
 /// <param name="dataTextField">text</param>
 /// <param name="emptyText">displayed text in emptyElement </param>
 public void FillDropDownList(DropDownList list, IEnumerable dataSource, String dataValueField = "", String dataTextField = "", bool needEmpty = false, String emptyText = "")
 {
     //if string[,] array is datasource
     if(dataSource.GetType() == typeof(System.String[,]))
     {
         list.DataSource = dataSource;
     }
     else //if any List<object> is datasource
     {
         list.DataSource = dataSource;
     }
     //if value or text fields are identified
     if(!string.IsNullOrEmpty(dataValueField))
     {
         list.DataValueField = dataValueField;
     }
     if(!string.IsNullOrEmpty(dataTextField))
     {
         list.DataTextField = dataTextField;
     }
     list.DataBind();
     //if we have to add an empty element to dropDownList
     if(needEmpty)
     {
         list.Items.Insert(0, new ListItem(emptyText, Constants.EpmtyDDLValue));
     }
 }
Example #55
0
        public void BindCampus(ref System.Web.UI.WebControls.DropDownList BranchDropdownList)
        {
            //try
            //{

            //    CommonMethods oCommonMethods = new CommonMethods();
            //    var admin = oCommonMethods.IsAdmin();

            //    if (admin)
            //    {

            //    }
            //    else
            //    {


            //    }



            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}
        }
Example #56
0
        /// <summary>
        /// Initializes a new instance of the <see cref="View" /> class.
        /// </summary>
        protected View()
            : base(HtmlTextWriterTag.Div)
        {
            Presenter = new Presenter(this);
            _answerCountLabel = new Label()
            {
                Text = ResourceHelper.GetString("AnswerCountDropDownLabel")
            };

            _answerCountDropDown = new DropDownList()
            {
                AutoPostBack = true
            };

            QuestionComposerControl = new QuestionComposer()
            {
                QuestionLabelText = ResourceHelper.GetString("QuestionLabelText"),
                AnswerLabelText = ResourceHelper.GetString("AnswerLabelText"),
                FractionLabelText = ResourceHelper.GetString("FractionLabelText"),
                ValidatorErrorMessage = ResourceHelper.GetString("FractionValidatorErrorMessage"),
                IsVisibleLabelText = ResourceHelper.GetString("IsVisibleLabelText")
            };

            _generateXmlButton = new Button()
            {
                Text = ResourceHelper.GetString("GenerateXMLButtonText")
            };

            _generateXmlButton.Click += GenerateXmlButton_Click;
        }
Example #57
0
        /// <summary>设置集合中的外包医院并返回集合
        /// 设置集合中的外包医院并返回集合
        /// </summary>
        /// <param name="isSendCustomer">是否加算外包医院</param>
        /// <returns></returns>
        private List <OrderRegister> GetGridTest(bool isSendCustomer)
        {
            List <OrderRegister> _gridtestList = ViewState["GridTest"] as List <OrderRegister>;

            if (isSendCustomer)
            {
                for (int i = 0; i < GridTest.Rows.Count; i++)
                {
                    System.Web.UI.WebControls.DropDownList ddloutcustomer = (System.Web.UI.WebControls.DropDownList)GridTest.Rows[i].FindControl("DropSendCustomer");
                    int sendcustomerid = Convert.ToInt32(ddloutcustomer.SelectedValue);
                    if (sendcustomerid != -1)
                    {
                        _gridtestList[i].Sendoutcustomerid = sendcustomerid;
                    }
                    else
                    {
                        _gridtestList[i].Sendoutcustomerid = null;
                    }
                }
            }
            //还未添加项目则new一个
            if (_gridtestList == null)
            {
                _gridtestList = new List <OrderRegister>();
            }

            return(_gridtestList);
        }
Example #58
0
        internal static void BindListInternal(DropDownList comboBox, object value, IEnumerable listSource, string textField, string valueField)
        {
            if (comboBox != null)
            {
                string selectedValue = !comboBox.Page.IsPostBack ? Convert.ToString(value) : comboBox.SelectedValue;

                if (listSource is Dictionary<string, string>)
                {
                    var items = listSource as Dictionary<string, string>;
                    foreach (var item in items)
                    {
                        comboBox.Items.Add(new ListItem(item.Key, item.Value));
                    }
                }
                else
                {
                    comboBox.DataTextField = textField;
                    comboBox.DataValueField = valueField;
                    comboBox.DataSource = listSource;

                    comboBox.DataBind();
                }

                //Reset SelectedValue
                comboBox.Select(selectedValue);
            }
        }
        //***************************************************************************
        // Private Methods
        // 
        protected override void CreateChildControls()
        {
            Panel pnl = FormElementControl.CreateControlContainer(this._qData, this.EditMode);
            this.Controls.Add(pnl);
            this.ControlContainer = pnl;

            DropDownList drp = new DropDownList();
            pnl.Controls.Add(drp);
            drp.AutoPostBack = true;
            drp.ID = "drpElement_" + this._qData.ElementProviderKey.ToString();
            if (this._qData.ElementWidth != Unit.Empty)
                drp.Width = this._qData.ElementWidth;
            if (this._qData.ElementHeight != Unit.Empty)
                drp.Height = this._qData.ElementHeight;
            if (this._qData.BackColor != System.Drawing.Color.Empty)
                drp.BackColor = this._qData.BackColor;
            if (this._qData.ForeColor != System.Drawing.Color.Empty)
                drp.ForeColor = this._qData.ForeColor;

            drp.Items.Add(new ListItem("- Select -", ""));
            foreach (FormElementDataAnswer item in this._qData.Answers.OrderBy(a => a.OrdinalPosition))
                drp.Items.Add(new ListItem(item.AnswerText, item.AnswerProviderKey.ToString()));

            this.AnswerControl = drp;

            base.CreateChildControls();
        }
Example #60
0
 /// <summary>
 /// 根据row设置控件的value
 /// </summary>
 /// <param name="row"></param>
 /// <param name="list"></param>
 public static void SetControlByRow(DataRow row, Dictionary <Control, string> list)
 {
     foreach (var i in list)
     {
         object val = row[i.Value];
         if (i.Key is System.Web.UI.WebControls.TextBox)//现时使用TextBox的有:decimal,int,string,DateTime.(NumberEditor是继承TextBox的)
         {
             System.Web.UI.WebControls.TextBox tmpControl = (System.Web.UI.WebControls.TextBox)i.Key;
             if (val != null && val != DBNull.Value)
             {
                 if (val is DateTime)
                 {
                     tmpControl.Text = PFDataHelper.ObjectToDateString(val, tmpControl.Attributes["dateFmt"]);
                 }
                 if (val is string)
                 {
                     tmpControl.Text = val.ToString();
                 }
                 if (val is decimal)
                 {
                     tmpControl.Text = val.ToString();
                 }
                 if (val is int)
                 {
                     tmpControl.Text = val.ToString();
                 }
             }
         }
         else if (i.Key is System.Web.UI.WebControls.DropDownList)
         {
             System.Web.UI.WebControls.DropDownList tmpControl = (System.Web.UI.WebControls.DropDownList)i.Key;
             tmpControl.SelectedValue = val.ToString();
         }
     }
 }