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; } } } } }
private void MessageConditionDropdownlist_SelectedIndexChanged(object sender, System.EventArgs e) { if (new Questions().GetAnswerableQuestionList(SurveyId).Questions.Count == 0) return; if (MessageConditionDropdownlist.SelectedValue == "2" || MessageConditionDropdownlist.SelectedValue == "3" || MessageConditionDropdownlist.SelectedValue == "4") { AddMessageConditionButton.Enabled = true; HideFields(true, true, false, false, true, true, true); } else if (MessageConditionDropdownlist.SelectedValue == "5") { AddMessageConditionButton.Enabled = true; HideFields(true, true, false, false, false, true, true); BindAnswerDropDownList(); } else if (MessageConditionDropdownlist.SelectedValue == "1") { AddMessageConditionButton.Enabled = true; HideFields(false,false, false, true, true, true, false); QuestionFilterDropdownlist.ClearSelection(); BindAnswerDropDownList(); } else { AddMessageConditionButton.Enabled = false; HideFields(true, true, true, true, true, true, true); } }
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 { } }
/// <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("数据控件不存在"); } }
private void page_bind() { objUser.id = intUserId; objUser.populate(); txtUsername.Text = "" + objUser.username; txtOrganisation.Text = "" + objUser.organisation; txtFirstname.Text = "" + objUser.firstName; txtLastname.Text = "" + objUser.lastName; txtEmail.Text = "" + objUser.email; dropDownType.ClearSelection(); foreach (ListItem objListItem in dropDownType.Items) { if (objListItem.Value == "" + objUser.type.ToString()) { objListItem.Selected = true; break; } } if (objUser.isActive == 0) { chkIsActive.Checked = false; } else { chkIsActive.Checked = true; } }
public static void SelectItem(DropDownList control, string value) { control.ClearSelection(); ListItem item = control.Items.FindByValue(value); if (item != null) item.Selected = true; }
// ============================================================================================================== #region ddlSupplier_SelectedIndexChanged private void ddlSupplier_SelectedIndexChanged(object sender, System.EventArgs e) { if (ddlSupplier.SelectedIndex != 0) { Invoice_NL_CN objInvoice = new Invoice_NL_CN(); try { ddlInvoiceNo.ClearSelection(); } catch { } ddlInvoiceNo.DataSource = objInvoice.GetInvoiceNo(Convert.ToInt32(ddlSupplier.SelectedValue), 2); ddlInvoiceNo.DataBind(); ddlInvoiceNo.Items.Insert(0, new ListItem("Select Doc No", "0")); try { ddldept.ClearSelection(); } catch { ddldept.DataSource = objInvoice.GetDepartmentListDropDown(); ddldept.DataBind(); ddldept.Items.Insert(0, new ListItem("Select", "0")); } } }
private void Btn_Entrada_Click(object sender, System.EventArgs e) { if (validar()) { string query = @"Select mtar_numero from DBXSCHEMA.MTARJETARELOJ where memp_codiempl='" + ddlTarjetasEmpleados.SelectedValue + "' or (pven_codigo='" + ddlTarjetasEmpleados.SelectedValue + "') and tvig_vigencia = 'V' "; string tarjeta = DBFunctions.SingleData(query); string nombre = ddlTarjetasEmpleados.SelectedItem.ToString(); DBFunctions.NonQuery("insert INTO DBXSCHEMA.DTARJETARELOJ VALUES(DEFAULT,'E'," + tarjeta + ",CURRENT TIMESTAMP)"); Utils.MostrarAlerta(Response, "BIENVENIDO " + nombre + " QUE TENGA UN BUEN DIA"); ddlTarjetasEmpleados.ClearSelection(); } else { Utils.MostrarAlerta(Response, "ERROR EN LA VALIDACION DEL USUARIO"); } //ddlTarjetasEmpleados.ClearSelection(); }
public static void DropDownListSelect(ref DropDownList ddl, string value) { ddl.ClearSelection(); ListItem li = ddl.Items.FindByValue(value); if (li != null) { li.Selected = true; } }
/// <summary> /// 设置下拉框选中 /// </summary> /// <param name="dropDownList">drop</param> /// <param name="value">选中值</param> public static void SetSelectedItem(DropDownList dropDownList, string value) { ListItem item = dropDownList.Items.FindByValue(value); if (item != null) { dropDownList.ClearSelection(); item.Selected = true; } }
private void LoadParentDropDown(DropDownList ddl, Category self) { // Load up the Parent DropDown ddl.ClearSelection(); ddl.Items.Add(new ListItem("none", "0")); foreach (Category cat in Category.Categories) { if (self == null || !cat.Id.Equals(self.Id)) ddl.Items.Add(new ListItem(cat.CompleteTitle(), cat.Id.ToString())); } }
private void CreateRegExHyperLink_Click(object sender, System.EventArgs e) { RegExOptionTitleLabel.Text = GetPageResource("CreateRegExOptionTitleLabel"); RegExDropDownList.ClearSelection(); ErrorMessageTextbox.Text = string.Empty; RegularExpressionTextbox.Text = string.Empty; RegExDescriptionTextbox.Text = string.Empty; ApplyChangesButton.Visible = false; DeleteRegExButton.Visible = false; MakeBuiltInRegExButton.Visible = false; CreateNewRegExButton.Visible = true; RegExOptionsPlaceHolder.Visible = true; }
/// <summary> /// Selects the item in the list control that contains the specified value, if it exists. /// </summary> /// <param name="dropDownList"></param> /// <param name="selectedValue">The value of the item in the list control to select</param> /// <returns>Returns true if the value exists in the list control, false otherwise</returns> public static bool SetSelectedValue(DropDownList dropDownList, String selectedValue) { dropDownList.ClearSelection(); ListItem selectedListItem = dropDownList.Items.FindByValue(selectedValue); if(selectedListItem != null) { selectedListItem.Selected = true; return true; } else { return false; } }
private void DataSourceDropDownList_SelectedIndexChanged(object sender, System.EventArgs e) { if (DataSourceDropDownList.SelectedValue == "3" && (!((PageBase)Page).CheckRight(NSurveyRights.SqlAnswerTypesEdition, false) || !GlobalConfig.SqlBasedAnswerTypesAllowed)) { MessageLabel.Visible = true; ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("SqlAnswerTypeAccessDeniedMessage")); DataSourceDropDownList.ClearSelection(); if (AnswerTypeId != -1) { BindFields(); } } InitUserInterface(); }
/// <Summary>RenderEditMode renders the Edit mode of the control</Summary> /// <Param name="writer">A HtmlTextWriter.</Param> protected override void RenderEditMode( HtmlTextWriter writer ) { PortalSettings _portalSettings = Globals.GetPortalSettings(); //For convenience create a DropDownList to use DropDownList cboTimeZones = new DropDownList(); //Load the List with Time Zones Localization.LoadTimeZoneDropDownList(cboTimeZones, ((PageBase)Page).PageCulture.Name, Convert.ToString(_portalSettings.TimeZoneOffset)); //Select the relevant item if (cboTimeZones.Items.FindByValue(StringValue) != null) { cboTimeZones.ClearSelection(); cboTimeZones.Items.FindByValue(StringValue).Selected = true; } //Render the Select Tag ControlStyle.AddAttributesToRender(writer); writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID); writer.RenderBeginTag(HtmlTextWriterTag.Select); for (int I = 0; I <= cboTimeZones.Items.Count - 1; I++) { string timeZoneValue = cboTimeZones.Items[I].Value; string timeZoneName = cboTimeZones.Items[I].Text; bool isSelected = cboTimeZones.Items[I].Selected; //Add the Value Attribute writer.AddAttribute(HtmlTextWriterAttribute.Value, timeZoneValue); if (isSelected) { //Add the Selected Attribute writer.AddAttribute(HtmlTextWriterAttribute.Selected, "selected"); } //Render Option Tag writer.RenderBeginTag(HtmlTextWriterTag.Option); writer.Write(timeZoneName.PadRight(100).Substring(0, 50)); writer.RenderEndTag(); } //Close Select Tag writer.RenderEndTag(); }
/// <summary> /// Selects the drop down item. /// </summary> /// <param name="dropdownListControl">The dropdown list control.</param> /// <param name="value">The value.</param> public static void SelectDropDownItem(DropDownList dropdownListControl, int value) { if (dropdownListControl == null) { throw new ArgumentNullException("Drop down control can not be null."); } dropdownListControl.ClearSelection();//clear existing selection. //find the value in the drop down item. ListItem item = dropdownListControl.Items.FindByValue(value.ToString()); if (item == null) //if item is null return to called method. { return; } item.Selected = true; }
/// <Summary>RenderEditMode renders the Edit mode of the control</Summary> /// <Param name="writer">A HtmlTextWriter.</Param> protected override void RenderEditMode( HtmlTextWriter writer ) { //For convenience create a DropDownList to use DropDownList cboLocale = new DropDownList(); //Load the List with Locales Localization.LoadCultureDropDownList(cboLocale, CultureDropDownTypes.NativeName, ((PageBase)Page).PageCulture.Name); //Select the relevant item if (cboLocale.Items.FindByValue(StringValue) != null) { cboLocale.ClearSelection(); cboLocale.Items.FindByValue(StringValue).Selected = true; } //Render the Select Tag ControlStyle.AddAttributesToRender(writer); writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID); writer.RenderBeginTag(HtmlTextWriterTag.Select); for (int I = 0; I <= cboLocale.Items.Count - 1; I++) { string localeValue = cboLocale.Items[I].Value; string localeName = cboLocale.Items[I].Text; bool isSelected = cboLocale.Items[I].Selected; //Add the Value Attribute writer.AddAttribute(HtmlTextWriterAttribute.Value, localeValue); if (isSelected) { //Add the Selected Attribute writer.AddAttribute(HtmlTextWriterAttribute.Selected, "selected"); } //Render Option Tag writer.RenderBeginTag(HtmlTextWriterTag.Option); writer.Write(localeName); writer.RenderEndTag(); } //Close Select Tag writer.RenderEndTag(); }
/// <summary> /// Pass in a DropDownList and typeof(YourEnum) as parameters to auto-bind a dropdownlist to an enum /// </summary> /// <param name="ddl">ddlMyDropDownList</param> /// <param name="enumType">typeof(MyEnum)</param> /// <param name="retainSelected">true/false indicating if the currently selected item should remain selected</param> public static void BindEnum2DropDownList(DropDownList ddl, Type enumType, bool retainSelected) { // retain the currently selected item if possible string currentlySelectedValue = string.Empty; if (retainSelected) currentlySelectedValue = ddl.SelectedValue; ddl.DataSource = GetListItemsFromEnum(enumType); ddl.DataTextField = "Text"; ddl.DataValueField = "Value"; ddl.DataBind(); // in the event that there was a selected item, keep it. if (currentlySelectedValue != string.Empty && retainSelected == true) { ddl.ClearSelection(); ddl.Items.FindByText(currentlySelectedValue).Selected = true; } }
/// ----------------------------------------------------------------------------- /// <summary> /// RenderViewMode renders the View (readonly) mode of the control /// </summary> /// <param name="writer">A HtmlTextWriter.</param> /// <history> /// [cnurse] 05/02/2006 created /// </history> /// ----------------------------------------------------------------------------- protected override void RenderViewMode(HtmlTextWriter writer) { PortalSettings _portalSettings = Globals.GetPortalSettings(); //For convenience create a DropDownList to use var cboTimeZones = new DropDownList(); //Load the List with Time Zones Localization.LoadTimeZoneDropDownList(cboTimeZones, ((PageBase) Page).PageCulture.Name, Convert.ToString(_portalSettings.TimeZoneOffset)); //Select the relevant item if (cboTimeZones.Items.FindByValue(StringValue) != null) { cboTimeZones.ClearSelection(); cboTimeZones.Items.FindByValue(StringValue).Selected = true; } ControlStyle.AddAttributesToRender(writer); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(cboTimeZones.SelectedItem.Text); writer.RenderEndTag(); }
protected void ddlprocDocs_Changed(object sender, System.EventArgs e) { // string documentoHTML = ""; string proceso = ddlprocDocs.SelectedValue; try { bind.PutDatasIntoDropDownList(ddlform, "SELECT DISTINCT * FROM (SELECT F.MSGC_CODIFORMA, F.MSGC_NOMBFORMA FROM MSGC_FORMATOS F WHERE F.MSGC_CODIPROC = '" + ddlprocDocs.SelectedValue + "' UNION SELECT M.MSGC_CODIFORMA, F.MSGC_NOMBFORMA FROM MSGC_PROCEDIMIENTOFORMATO M, MSGC_FORMATOS F WHERE F.MSGC_CODIPROC = M.MSGC_CODIPROC AND M.MSGC_CODIPROC = '" + proceso + "') "); ddlform.Items.Insert(0, "seleccione..."); archivo = DBFunctions.SingleData("SELECT MSGC_DOCUADJU ARCHIVO FROM dbxschema.MSGC_PROCEDIMIENTO WHERE MSGC_CODIPROC = '" + ddlprocDocs.SelectedValue + "'"); if (archivo == null || archivo == "") { return; } documento = ConfigurationManager.AppSettings["Uploads"] + archivo; Response.Write("<script type=\"text/javascript\">w=window.open(\"" + documento + "\",\"Documento\",\"width=800,height=600\");</script>"); } catch { ddlform.ClearSelection(); ddlform.Items.Insert(0, "No hay Documentos..."); } //documentoHTML = DBFunctions.SingleData("select msgc_documento from msgc_procedimiento where msgc_codiproc = '" + proceso + "'"); }
private void ddlSupplier_SelectedIndexChanged(object sender, System.EventArgs e) { if (ddlSupplier.SelectedIndex != 0) { try { grdInvCur.CurrentPageIndex = 0; } catch { } Invoice objInvoice = new Invoice(); try { ddlInvoiceNo.ClearSelection(); } catch { } ddlInvoiceNo.DataSource = objInvoice.GetInvoiceNo(Convert.ToInt32(ddlSupplier.SelectedValue), 2, Convert.ToInt32(Session["UserTypeID"])); ddlInvoiceNo.DataBind(); ddlInvoiceNo.Items.Insert(0, new ListItem("Select Doc No", "0")); try { ddldept.ClearSelection(); } catch { if (Convert.ToInt32(Session["UserTypeID"]) > 1) { ddldept.DataSource = objInvoice.GetDepartmentListDropDown(1, 0); ddldept.DataBind(); ddldept.Items.Insert(0, new ListItem("Select", "0")); } else { ddldept.DataSource = objInvoice.GetDepartmentListDropDown(0, Convert.ToInt32(Session["UserID"])); ddldept.DataBind(); ddldept.Items.Insert(0, new ListItem("Select", "0")); } } } }
/// <summary> /// Método necesario para admitir el Diseñador. No se puede modificar /// el contenido del método con el editor de código. /// </summary> //private void InitializeComponent() //{ // this.ddlproc.SelectedIndexChanged += new System.EventHandler(this.ddlproc_SelectedIndexChanged); // this.ddlform.SelectedIndexChanged += new System.EventHandler(this.ddlform_SelectedIndexChanged); // this.Button1.Click += new System.EventHandler(this.Button1_Click); // this.Load += new System.EventHandler(this.Page_Load); //} #endregion protected void ddlproc_SelectedIndexChanged(object sender, System.EventArgs e) { archivo = ""; documento = ""; string proceso = ddlproc.SelectedValue; //Label2.Text="Formatos Relacionados"; try { bind.PutDatasIntoDropDownList(ddlprocDocs, "select MSGC_CODIPROC,MSGC_NOMBPROC from dbxschema.MSGC_PROCEDIMIENTO where PARE_CODIGO = '" + ddlproc.SelectedValue + "' order by MSGC_NOMBPROC;"); ddlprocDocs.Items.Insert(0, "seleccione..."); } catch { ddlprocDocs.ClearSelection(); ddlprocDocs.Items.Insert(0, "seleccione..."); } bindFormatos(proceso); archivo = DBFunctions.SingleData("select MSGC_RUTAARCH from dbxschema.MSGC_PROCEDIMIENTO where MSGC_CODIPROC='" + proceso + "'"); if (archivo == null || archivo == "") { return; } documento = ConfigurationManager.AppSettings["PathToManuales"] + archivo; Response.Write("<script type=\"text/javascript\">w=window.open(\"" + documento + "\",\"Documento\",\"width=800,height=600\");</script>"); }
private void AddMore_Click(object sender, System.EventArgs e) { NumberOfPeople.Text = ""; CompanyName.ReadOnly = true; ReprName.ReadOnly = true; Telephone.ReadOnly = true; StartDate.ReadOnly = true; ReturnDate.ReadOnly = true; BrowseCalendar1.Enabled = false; BrowseCalendar2.Enabled = false; Total.Text = ""; DDLDestination.EnableViewState = true; DDLDestination.Enabled = false; DDLVehicleType.ClearSelection(); ListVehicles.ClearSelection(); Save.Enabled = true; AddMore.Enabled = false; }
//********************************************************************************** //********************************************************************************** #region "FillDropDownList" public void FillDropDownList(System.Web.UI.WebControls.DropDownList ddl, System.Data.DataSet ds, string valueField, string textField, string firstRowValue, string firstRowText, string selectedValue) { ddl.Items.Clear(); ddl.DataTextField = textField; ddl.DataValueField = valueField; ddl.DataSource = ds; ddl.DataBind(); //add first row if (firstRowValue != null && firstRowValue != "") { System.Web.UI.WebControls.ListItem l = new System.Web.UI.WebControls.ListItem(firstRowText, firstRowValue); ddl.Items.Insert(0, l); } if (selectedValue != null && selectedValue != "") { //set the seleted index for selected value System.Web.UI.WebControls.ListItem li = ddl.Items.FindByValue(selectedValue); ddl.ClearSelection(); if (li != null) { li.Selected = true; } } }
public JsonResult ObtenTipoVehi(string subRamo, string straño, string nMarcaId, string SubMarca, string Marca) { try { MensajesError.tipo = "T"; DropDownList ddTipo = new DropDownList(); if (subRamo == "L" && straño != "" && nMarcaId != "" && SubMarca != "") { //Cargo las SubMarcas CmbCatalogos llenaCombos = new CmbCatalogos(); llenaCombos.cargaCmbTipoVehiWeb(ddTipo, straño, nMarcaId, SubMarca); } else { ddTipo.DataSource = MnInf.FiltrarWebCmb(VarProcAMC.strPeriodo, straño, Marca, SubMarca); ; ddTipo.DataTextField = "Descripcion".Trim(); ddTipo.DataValueField = "Clave"; ddTipo.DataBind(); //CmbSubMarca.Items.Insert(0, "<TODAS>"); ddTipo.ClearSelection(); } var tipoVeh = ddTipo.Items; return Json(new SelectList(tipoVeh, "Value", "Text")); } catch (Exception err) { Response.StatusCode = (int)(System.Net.HttpStatusCode.InternalServerError); LogDeErrores.RegistroErrorWeb(err, DatoUsuario.idAgente, DatoUsuario.nomAgente, DatoUsuario.sIp, DatoUsuario.sHostName); return Json("ErrInterno"); } }
private void Page_Load(object sender, System.EventArgs e) { if (Page.IsPostBack == false) { //Remove validation for Windows users if (HttpContext.Current != null && Context.User is System.Security.Principal.WindowsPrincipal) { this.ValidEmail.Visible = false; this.EmailLabel.TextKey = "WINDOWS_USER_NAME"; this.EmailLabel.Text = "Windows User Name"; } //If allow id and user is not new show id row //When we create an user, id is ignored if (allowEditUserID && userName.Length != 0) { UserIDRow.Visible = true; } BindCountry(); //Bind to current language country CountryField.ClearSelection(); Esperantus.CountryInfo country = Esperantus.CountryInfo.CurrentCountry; if (country != null && CountryField.Items.FindByValue(country.Name) != null) { CountryField.Items.FindByValue(country.Name).Selected = true; } BindState(); // Edit check if (EditMode) // Someone requested edit this record { //True is use is editing himself, false if is edited by an admin selfEdit = (userName == PortalSettings.CurrentUser.Identity.Email); // Removed by Mario Endara <*****@*****.**> (2004/11/04) // if (PortalSecurity.IsInRoles("Admins") || selfEdit) if (PortalSecurity.HasEditPermissions(ModuleID) || PortalSecurity.HasAddPermissions(ModuleID) || selfEdit) { //We can edit // Hide RequiredPassword.Visible = false; RequiredConfirm.Visible = false; EditPasswordRow.Visible = true; SaveChangesBtn.Visible = true; RegisterBtn.Visible = false; // Obtain a single row of event information UsersDB accountSystem = new UsersDB(); SqlDataReader dr = accountSystem.GetSingleUser(userName, portalSettings.PortalID); try { // Read first row from database if (dr.Read()) { UseridField.Text = dr["UserID"].ToString(); //stores original user id for later check originalUserID = int.Parse(dr["UserID"].ToString()); NameField.Text = dr["Name"].ToString(); EmailField.Text = dr["Email"].ToString(); CompanyField.Text = dr["Company"].ToString(); AddressField.Text = dr["Address"].ToString(); ZipField.Text = dr["Zip"].ToString(); CityField.Text = dr["City"].ToString(); CountryField.ClearSelection(); if (CountryField.Items.FindByValue(dr["CountryID"].ToString()) != null) { CountryField.Items.FindByValue(dr["CountryID"].ToString()).Selected = true; } BindState(); StateField.ClearSelection(); if (StateField.Items.Count > 0 && StateField.Items.FindByValue(dr["StateID"].ToString()) != null) { StateField.Items.FindByValue(dr["StateID"].ToString()).Selected = true; } FaxField.Text = dr["Fax"].ToString(); PhoneField.Text = dr["Phone"].ToString(); CFiscaleField.Text = dr["CFiscale"].ToString(); PIvaField.Text = dr["PIva"].ToString(); SendNewsletter.Checked = bool.Parse(dr["SendNewsletter"].ToString()); //stores original password for later check originalPassword = dr["Password"].ToString(); } } finally { dr.Close(); } } else { //We do not have rights to do it! Security.PortalSecurity.AccessDeniedEdit(); } } else { BindState(); //No edit RequiredPassword.Visible = true; RequiredConfirm.Visible = true; EditPasswordRow.Visible = false; SaveChangesBtn.Visible = false; RegisterBtn.Visible = true; } string termsOfService = portalSettings.GetTermsOfService; //Verify if we have to show conditions if (termsOfService != string.Empty) { //Shows conditions FieldConditions.Text = termsOfService; ConditionsRow.Visible = true; } else { //Hides conditions ConditionsRow.Visible = false; } } }
protected void clearSelection_Click(object sender, EventArgs args) { list.ClearSelection(); }
protected void MakeSafeListSelection(DropDownList listCtl, string valueSelected) { if (listCtl == null) return; // var li = listCtl.Items.FindByValue(valueSelected); // if (li == null) return; // listCtl.ClearSelection(); li.Selected = true; }
public static void SetValue(string boField, bool boFieldIsNull, DropDownList dropDownList) { dropDownList.ClearSelection(); if (boFieldIsNull) { return; } else { ListItem li = dropDownList.Items.FindByValue(boField); if (!(li == null)) { li.Selected = true; } } }
protected override void InitializePager(DataGridItem item, int columnSpan, PagedDataSource pagedDataSource) { int colspan = 0; if (LayoutFixed) { foreach (DataGridColumn dgc in this.Columns) if (dgc.Visible) colspan++; this.Style.Add("table-layout", "fixed"); } else colspan = columnSpan; Table tbl = new Table(); tbl.CellPadding = 3; tbl.CellSpacing = 0; tbl.BorderWidth = Unit.Pixel(0); tbl.CssClass = "ibn-propertysheet"; tbl.Width = Unit.Percentage(100); TableRow tr1 = new TableRow(); TableCell tableCell = new TableCell(); tableCell.HorizontalAlign = HorizontalAlign.Right; //tableCell.ColumnSpan = columnSpan; DataGridPagerStyle dataGridPagerStyle = PagerStyle; Label lbl = new Label(); //lbl.CssClass = PagerStyle.CssClass; lbl.Text = LocRM.GetString("Page") + ": "; tableCell.Controls.Add(lbl); TableCell tableCellL = new TableCell(); Label lblPageSize = new Label(); //lblPageSize.CssClass = PagerStyle.CssClass; lblPageSize.Text = LocRM.GetString("PageSize") + ": "; DropDownList ddl = new DropDownList(); ddl.ClearSelection(); ddl.Items.Add(new ListItem(LocRM.GetString("10i"), "10")); ddl.Items.Add(new ListItem(LocRM.GetString("25i"), "25")); ddl.Items.Add(new ListItem(LocRM.GetString("50i"), "50")); ddl.Items.Add(new ListItem(LocRM.GetString("100i"), "100")); CommonHelper.SafeSelect(ddl, PageSize.ToString()); // pager.BorderWidth = Unit.Pixel(1); ddl.CssClass = "text"; ddl.AutoPostBack = true; ddl.SelectedIndexChanged += new System.EventHandler(OnChangePageSize); tableCellL.Controls.Add(lblPageSize); tableCellL.Controls.Add(ddl); int i1 = pagedDataSource.PageCount; int j1 = pagedDataSource.CurrentPageIndex + 1; int k1 = dataGridPagerStyle.PageButtonCount; int i2 = k1; if (i1 < i2) { i2 = i1; } int j2 = 1; int k2 = i2; if (j1 > k2) { j2 = pagedDataSource.CurrentPageIndex / k1 * k1 + 1; k2 = j2 + k1 - 1; if (k2 > i1) { k2 = i1; } if (k2 - j2 + 1 < k1) { j2 = Math.Max(1, k2 - k1 + 1); } } if (j2 != 1) { LinkButton linkButton3 = new DataGridExtendedLinkButton(); linkButton3.Text = "..."; linkButton3.CommandName = "Page"; int k3 = j2 - 1; linkButton3.CommandArgument = k3.ToString(NumberFormatInfo.InvariantInfo); linkButton3.CausesValidation = false; tableCell.Controls.Add(linkButton3); tableCell.Controls.Add(new LiteralControl(" ")); } for (int j3 = j2; j3 <= k2; j3++) { string str = j3.ToString(NumberFormatInfo.InvariantInfo); if (j3 == j1) { Label label3 = new Label(); label3.Font.Bold = true; label3.Text = str; tableCell.Controls.Add(label3); } else { LinkButton linkButton3 = new DataGridExtendedLinkButton(); linkButton3.Text = "[ " + str + " ]"; linkButton3.CommandName = "Page"; linkButton3.CommandArgument = str; linkButton3.CausesValidation = false; tableCell.Controls.Add(linkButton3); } if (j3 < k2) { tableCell.Controls.Add(new LiteralControl(" ")); } } if (i1 > k2) { tableCell.Controls.Add(new LiteralControl(" ")); LinkButton linkButton3 = new DataGridExtendedLinkButton(); linkButton3.Text = "[ ... ]"; linkButton3.CommandName = "Page"; int k3 = k2 + 1; linkButton3.CommandArgument = k3.ToString(NumberFormatInfo.InvariantInfo); linkButton3.CausesValidation = false; tableCell.Controls.Add(linkButton3); } tbl.Rows.Add(tr1); tr1.Cells.Add(tableCellL); tr1.Cells.Add(tableCell); TableCell tc = new TableCell(); tc.ColumnSpan = colspan; tc.CssClass = "ibn-vb2"; tc.Controls.Add(tbl); item.Cells.Add(tc); }
private static DropDownList CreateDropDownQuestion( mojoProfilePropertyDefinition propertyDefinition, String propertyValue) { DropDownList dd = new DropDownList(); if (dd.Items.Count == 0) { foreach (mojoProfilePropertyOption option in propertyDefinition.OptionList) { ListItem listItem = new ListItem(); listItem.Value = option.Value; listItem.Text = option.TextResourceKey; if (option.TextResourceKey.Length > 0) { if (HttpContext.Current != null) { Object obj = HttpContext.GetGlobalResourceObject( propertyDefinition.ResourceFile, option.TextResourceKey); if (obj != null) { listItem.Text = obj.ToString(); } } } dd.Items.Add(listItem); } } ListItem defaultItem = dd.Items.FindByValue(propertyValue); if (defaultItem != null) { dd.ClearSelection(); defaultItem.Selected = true; } return dd; }
/// <Summary> /// RenderViewMode renders the View (readonly) mode of the control /// </Summary> /// <Param name="writer">A HtmlTextWriter.</Param> protected override void RenderViewMode( HtmlTextWriter writer ) { //For convenience create a DropDownList to use DropDownList cboLocale = new DropDownList(); //Load the List with Locales Localization.LoadCultureDropDownList(cboLocale, CultureDropDownTypes.NativeName, ((PageBase)Page).PageCulture.Name); //Select the relevant item if (cboLocale.Items.FindByValue(StringValue) != null) { cboLocale.ClearSelection(); cboLocale.Items.FindByValue(StringValue).Selected = true; } ControlStyle.AddAttributesToRender(writer); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(cboLocale.SelectedItem.Text); writer.RenderEndTag(); }
/// <summary> /// 设置下列列表控件的SelectedValue /// </summary> /// <param name="control">DropDownList控件</param> /// <param name="strValue">SelectedValue的值</param> public static void SetDropDownListItem(DropDownList control, string strValue) { if (!IsNullorEmpty(strValue)) { control.ClearSelection(); ListItem item = control.Items.FindByValue(strValue); if (item != null) { control.SelectedValue = item.Value; } } }
/// <summary> /// Binds the drop down list. /// </summary> /// <param name="dropDown">The drop down.</param> /// <param name="value">The value.</param> private void BindDropDownList(DropDownList dropDown, string value) { for (int intIndex = 0; intIndex < dropDown.Items.Count; intIndex++) { if (string.Equals(dropDown.Items[intIndex].Text, value)) { dropDown.ClearSelection(); dropDown.Items[intIndex].Selected = true; } } }
/// <summary> /// Binds the drop down list. /// </summary> /// <param name="dropDown">The drop down.</param> /// <param name="value">The value.</param> private void BindDropDownList(DropDownList ddlControl, string value) { for (int intIndex = 0; intIndex < ddlControl.Items.Count; intIndex++) { if (string.Equals(ddlControl.Items[intIndex].Text.ToString(), value)) { ddlControl.ClearSelection(); ddlControl.Items[intIndex].Selected = true; break; } } }
public static void SetSelectedValue(DropDownList ComboBox, string SelectedValue) { ListItem SelectedItem = ComboBox.Items.FindByValue(SelectedValue); if (SelectedItem != null) { ComboBox.ClearSelection(); SelectedItem.Selected = true; ComboBox.Enabled = false; } }
/// <summary> /// The BindData helper method is used to populate a asp:datalist /// server control with the current "edit access" permissions /// set within the portal configuration system /// </summary> private void BindData() { bool useNTLM = HttpContext.Current.User is System.Security.Principal.WindowsPrincipal; // add by Jonathan Fong 22/07/2004 to support LDAP useNTLM |= System.Configuration.ConfigurationSettings.AppSettings["LDAPLogin"] != null ? true : false; authAddRoles.Visible = authApproveRoles.Visible = authDeleteRoles.Visible = authEditRoles.Visible = authPropertiesRoles.Visible = authPublishingRoles.Visible = authMoveModuleRoles.Visible = authDeleteModuleRoles.Visible = authViewRoles.Visible = !useNTLM; memAddRoles.Visible = memApproveRoles.Visible = memDeleteRoles.Visible = memEditRoles.Visible = memPropertiesRoles.Visible = memPublishingRoles.Visible = memMoveModuleRoles.Visible = memDeleteModuleRoles.Visible = memViewRoles.Visible = useNTLM; object value = GetModule(); if (value != null) { ModuleSettings m = (ModuleSettings)value; moduleType.Text = giveMeFriendlyName(m.GuidID); // Update Textbox Settings moduleTitle.Text = m.ModuleTitle; cacheTime.Text = m.CacheTime.ToString(); portalTabs = new TabsDB().GetTabsFlat(portalSettings.PortalID); tabDropDownList.DataBind(); tabDropDownList.ClearSelection(); if (tabDropDownList.Items.FindByValue(m.TabID.ToString()) != null) { tabDropDownList.Items.FindByValue(m.TabID.ToString()).Selected = true; } // Change by [email protected] //Date: 19/5/2003 showEveryWhere.Checked = m.ShowEveryWhere; // is the window mgmt support enabled allowCollapsable.Enabled = Rainbow.BLL.Utils.GlobalResources.SupportWindowMgmt; allowCollapsable.Checked = m.SupportCollapsable; ShowMobile.Checked = m.ShowMobile; // Change by [email protected] // Date: 6/2/2003 PortalModuleControl pm; string controlPath; controlPath = Rainbow.Settings.Path.WebPathCombine(Rainbow.Settings.Path.ApplicationRoot, m.DesktopSrc); try { pm = (PortalModuleControl)LoadControl(controlPath); if (pm.InnerSupportsWorkflow) { enableWorkflowSupport.Checked = m.SupportWorkflow; if (useNTLM) { memApproveRoles.Enabled = m.SupportWorkflow; memPublishingRoles.Enabled = m.SupportWorkflow; memApproveRoles.Members = m.AuthorizedApproveRoles; memPublishingRoles.Members = m.AuthorizedPublishingRoles; } else { authApproveRoles.Enabled = m.SupportWorkflow; authPublishingRoles.Enabled = m.SupportWorkflow; populateRoles(ref authPublishingRoles, m.AuthorizedPublishingRoles); populateRoles(ref authApproveRoles, m.AuthorizedApproveRoles); } } else { enableWorkflowSupport.Enabled = false; if (useNTLM) { memApproveRoles.Enabled = false; memPublishingRoles.Enabled = false; } else { authApproveRoles.Enabled = false; authPublishingRoles.Enabled = false; } } } catch (Exception ex) { Rainbow.Configuration.ErrorHandler.HandleException("There was a problem loading: '" + controlPath + "'", ex); throw; } // End Change [email protected] // Populate checkbox list with all security roles for this portal // and "check" the ones already configured for this module if (useNTLM) { memEditRoles.Members = m.AuthorizedEditRoles; memViewRoles.Members = m.AuthorizedViewRoles; memAddRoles.Members = m.AuthorizedAddRoles; memDeleteRoles.Members = m.AuthorizedDeleteRoles; memMoveModuleRoles.Members = m.AuthorizedMoveModuleRoles; memDeleteModuleRoles.Members = m.AuthorizedDeleteModuleRoles; memPropertiesRoles.Members = m.AuthorizedPropertiesRoles; } else { populateRoles(ref authEditRoles, m.AuthorizedEditRoles); populateRoles(ref authViewRoles, m.AuthorizedViewRoles); populateRoles(ref authAddRoles, m.AuthorizedAddRoles); populateRoles(ref authDeleteRoles, m.AuthorizedDeleteRoles); populateRoles(ref authMoveModuleRoles, m.AuthorizedMoveModuleRoles); populateRoles(ref authDeleteModuleRoles, m.AuthorizedDeleteModuleRoles); populateRoles(ref authPropertiesRoles, m.AuthorizedPropertiesRoles); } // Jes1111 if (!pm.Cacheable) { cacheTime.Text = "-1"; cacheTime.Enabled = false; } } else // Denied access if Module not in Tab. [email protected] (2004/07/23) { PortalSecurity.AccessDenied(); } }
private void FillWhenToCompareValue(DropDownList ddlWhenToCompare) { ddlWhenToCompare.ClearSelection(); ddlWhenToCompare.Items.Add(new ListItem("Always", ConditionComparisionType.Always.ToString())); ddlWhenToCompare.Items.Add(new ListItem("After change", ConditionComparisionType.AfterChange.ToString())); }
/// <summary> /// Binds the drop down list. /// </summary> /// <param name="dropDown">The drop down.</param> /// <param name="value">The value.</param> private void BindCountryDropDownList(DropDownList dropDown, string value) { //for (int intIndex = 0; intIndex < dropDown.Items.Count; intIndex++) //{ // if (string.Equals(dropDown.Items[intIndex].Text, value)) // { // dropDown.Items[intIndex].Selected = true; // } //} if (dropDown != null) { if (dropDown.Items.FindByValue(value) != null) { dropDown.ClearSelection(); dropDown.Items.FindByValue(value).Selected = true; } else if (dropDown.Items.FindByText(value) != null) { dropDown.ClearSelection(); dropDown.Items.FindByText(value).Selected = true; } } }
private void SetListToValue(DropDownList l, string value) { if (l != null) { if (l.Items.FindByValue(value) != null) { l.ClearSelection(); l.Items.FindByValue(value).Selected = true; } } }
private void SelectDropDownListItem(ref DropDownList ddl, string key) { if (Settings.ContainsKey(key)) { ddl.ClearSelection(); var selItem = ddl.Items.FindByValue(Convert.ToString(Settings[key])); if (selItem != null) { selItem.Selected = true; } } }
public static void Modulos(DropDownList ddl) { try { ddl.DataSource = CRB.BOSS.Autenticacao.Modulo.Modulo.RecuperarTodos(); ddl.DataTextField = "NME_MODULO"; ddl.DataValueField = "COD_MODULO"; ddl.DataBind(); ddl.Items.Insert(0, new ListItem(Informacoes.ComboVazio, "")); ddl.ClearSelection(); CRB.BOSS.Auditoria.Log.Log.Salvar("Carregar combo de modulo", CRB.BOSS.Auditoria.Log.InformacoesLog.Information, CRB.BOSS.Autenticacao.Modulo.Modulo.Funcionalidade, CRB.BOSS.Autenticacao.Modulo.Modulo.Atual); } catch (Exception ex) { CRB.BOSS.Auditoria.Log.Log.Salvar(ex.Message, CRB.BOSS.Auditoria.Log.InformacoesLog.Information, CRB.BOSS.Autenticacao.Modulo.Modulo.Funcionalidade, CRB.BOSS.Autenticacao.Modulo.Modulo.Atual); throw ex; } }
/// <summary> /// Binds the drop down list. /// </summary> /// <param name="dropDown">The drop down.</param> /// <param name="value">The value.</param> private void BindDropDownList(DropDownList dropDown, string value) { if (dropDown != null) { if (dropDown.Items.FindByText(value) != null) { dropDown.ClearSelection(); dropDown.Items.FindByText(value).Selected = true; } } }
private void SetPrivacy(DropDownList ddl, string privacyLevel) { ddl.ClearSelection(); ListItem li = ddl.Items.FindByValue(privacyLevel); if (!(li == null)) { li.Selected = true; } }
/// <summary> /// Setup the control in creation mode /// </summary> private void SwitchToCreationMode() { // Creation mode AddAnswerButton.Visible = true; UpdateAnswerButton.Visible = false; DeleteAnswerButton.Visible = false; SelectedAnswersLabel.Visible = true; SelectionCheckBox.Visible = true; RatingPartCheckbox.Visible = RatingEnabled; AnswerRatingLabel.Visible = RatingEnabled; AnswerTextTextBox.Text = String.Empty; AnswerPipeAliasTextBox.Text = String.Empty; DefaultTextTextBox.Text = String.Empty; ScoreTextBox.Text = String.Empty; ScoreTextBox.Visible = ScoreEnabled; ScoreLabel.Visible = ScoreEnabled; txtAnswerAlias.Text = string.Empty; txtAnswerID.Text = string.Empty; EditAnswerTitle.Text = ((PageBase)Page).GetPageResource("AddNewAnswerTitle"); RegExDropDownList.ClearSelection(); MandatoryLabel.Visible = false; MandatoryCheckBox.Checked = false; RegExValidationLabel.Visible = false; RegExDropDownList.Visible = false; MandatoryCheckBox.Visible = false; ConnectionsPlaceHolder.Visible = false; SliderRangeLabel.Visible = false; SliderRangeDDL.Visible = false; SliderRangeDDL.Text = SliderRangeDDL.SelectedValue.ToString(); SliderValueTextBox.Visible = false; SliderValueLabel.Visible = false; SliderValueTextBox.Text = String.Empty; SliderMinLabel.Visible = false; SliderMinTextBox.Visible = false; SliderMinTextBox.Text = String.Empty; SliderMaxLabel.Visible = false; SliderMaxTextBox.Visible = false; SliderMaxTextBox.Text = String.Empty; SliderAnimateLabel.Visible = false; SliderAnimateCheckbox.Visible = false; SliderAnimateCheckbox.Checked = false; SliderStepLabel.Visible = false; SliderStepTextBox.Visible = false; SliderStepTextBox.Text = String.Empty; DefaultTextLabel.Visible = false; DefaultTextTextBox.Visible = false; AnswerPipeAliasLabel.Visible = false; AnswerPipeAliasTextBox.Visible = false; PipeHelpLabel.Visible = false; ExtendedPropertiesPlaceholder.Controls.Clear(); ExtendedPropertiesPlaceholder.Visible = false; ExtendedPlaceholder.Visible = false; }
private void SelectValue(DropDownList ddl, DateTypes DateType) { ddl.ClearSelection(); using (IDataReader reader = Schedule.GetReminderSubscriptionGlobal(DateType)) { /// SubscriptionId, DateTypeId, UserId, ObjectId, Lag, IsActive, HookId if (reader.Read()) { if ((bool)reader["IsActive"]) Util.CommonHelper.SafeSelect(ddl, reader["Lag"].ToString()); } } }
public void SelectValueDropDownList(DropDownList DropDownList, string value) { ListItem item = DropDownList.Items.FindByValue(value); if (item != null) { DropDownList.ClearSelection(); item.Selected = true; } }