public void DataBindEx() { DataSet ds = (new T_QuestionType_BLL()).GetList(""); DropDown1.DataTextField = "Title"; DropDown1.DataValueField = "QuestionTypeID"; DropDown1.DataSource = ds; DropDown1.DataBind(); }
// BEWARE THIS IS EXTREMELY STUPID CODE. I'm just too tired to make anything nice rn private async void OnExpanderTapped(object sender, EventArgs e) { if (DropDown1.Rotation == 0) { await DropDown1.RotateTo(180, 1); } else { await DropDown1.RotateTo(0, 1); } }
/// <summary> /// The code that should run once when a control is loaded /// Base code should have "virtual" /// Derived classes should have "override" /// </summary> public virtual void InitializeFieldTemplate() { string DefaultValue = GetMetaDataValue(MetaDataDefaultValueKey, ""); // Do things depending which InputType this control has set if (InputType == InputTypes.Wysiwyg) { TextBox1.Visible = false; Texteditor1.Visible = true; //if (MetaData.ContainsKey(MetaDataWysiwygHeightKey)) //{ var WysiwygHeight = GetMetaDataValue(MetaDataWysiwygHeightKey, new decimal?()); // (((IAttribute<decimal?>)(MetaData[MetaDataWysiwygHeightKey]))).Typed[DimensionIds]; if (WysiwygHeight.HasValue) { Texteditor1.Height = new Unit(Convert.ToInt32(WysiwygHeight)); } //} if (MetaData.ContainsKey(MetaDataWysiwygWidthKey)) { var WysiwygWidth = (((IAttribute <decimal?>)(MetaData[MetaDataWysiwygWidthKey]))).Typed[DimensionIds]; if (WysiwygWidth.HasValue) { Texteditor1.Width = new Unit(Convert.ToInt32(WysiwygWidth)); } } if (FieldValueEditString != null) { Texteditor1.Text = FieldValueEditString; } else { Texteditor1.Text = DefaultValue; } Texteditor1.ChooseMode = false; } else if (InputType == InputTypes.DropDown) { TextBox1.Visible = false; DropDown1.Visible = true; if (!String.IsNullOrEmpty(GetMetaDataValue <string>(MetaDataDrowdownValuesKey))) { DropDown1.DataSource = (from c in GetMetaDataValue <string>(MetaDataDrowdownValuesKey).Replace("\r", "").Split('\n') select new { Text = c.Contains(':') ? (c.Split(':'))[0] : c, Value = c.Contains(':') ? (c.Split(':'))[1] : c }).ToList(); } DropDown1.DataBind(); if (!String.IsNullOrEmpty(FieldValueEditString)) { if (DropDown1.Items.Cast <ListItem>().All(i => i.Value != FieldValueEditString)) { DropDown1.Items.Insert(0, new ListItem(FieldValueEditString + " (keep old value)", FieldValueEditString)); } DropDown1.SelectedValue = FieldValueEditString; } if (FieldValueEditString == null) { DropDown1.SelectedValue = DefaultValue; } } else if (InputType == InputTypes.Link) { TextBox1.Visible = false; DnnUrl1.Visible = true; DnnUrl1.Url = FieldValueEditString; } else { // Row Count of multiline field var metaDataRowCount = GetMetaDataValue <decimal?>(MetaDataRowCountKey); if (metaDataRowCount.HasValue && metaDataRowCount > 0) { TextBox1.Rows = Convert.ToInt32(metaDataRowCount.Value.ToString()); if (TextBox1.Rows > 1) { TextBox1.TextMode = System.Web.UI.WebControls.TextBoxMode.MultiLine; } } if (GetMetaDataValue <bool>(MetaDataIsRequiredKey)) { TextBox1.CssClass += " dnnFormRequired"; } var metaDataLength = GetMetaDataValue <int?>(MetaDataLengthKey); if (metaDataLength.HasValue && metaDataLength > 0) { TextBox1.MaxLength = metaDataLength.Value; } TextBox1.ToolTip = GetMetaDataValue <string>(MetaDataNotesKey); if (FieldValueEditString != null) { TextBox1.Text = FieldValueEditString; } else { TextBox1.Text = DefaultValue; } } if (ShowDataControlOnly) { FieldLabel.Visible = false; } valFieldValue.DataBind(); var metaRegularExpressions = GetMetaDataValue <string>(MetaDataRegularExpression); if (!String.IsNullOrEmpty(metaRegularExpressions)) { valRegularExpression.ValidationExpression = metaRegularExpressions; } valRegularExpression.DataBind(); }