This article is in continuation of my previous article on creating a multiselect dropdownlist using bootstrap in ASP.NET. If you haven’t had a look at it please go through the following link.
In the above article we simply developed a bootstrap Multiselect DropDownList user control with less features. The following are the merits and demerits of the built control:
Merits
- It allows the user to select multiple items from a dropdownlist at a single point of time.
- By setting a single property we can make the control as “Multi Select” or “Single Select”.
- We also saw that the control is capable of maintaining its state during postback / server round trips.
Demerits
- The control is not making full use of JavaScript features such as polymorphism, method overriding, etc.
- Also it lacks server side properties of dropdownlist like AutoPostBack, ValidationGroup, SelectedIndexChanged event, etc.
- Did not impose any validation like requiredField validator on the dropdownlist control.
- UI wise improvement can be done.
In this article we’ll try to enhance our user control so that all the drawbacks can be taken care of. So let’s update our control properties and script files accordingly.
AutoCompleteDdl.aspx code
- <%@ControlLanguage="C#"AutoEventWireup="true"CodeFile="AutoCompleteDdl.ascx.cs"Inherits="User_Control_AutoCompleteDdl"%>
- <divstyledivstyledivstyledivstyledivstyledivstyledivstyledivstyle="width: 380px;"id="divAutoComplete"runat="server">
- <asp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldID="hdnButtonWidth"runat="server"Value="320px"/>
- <asp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldID="hdnNonSelectedText"runat="server"Value="--Select--"/>
- <asp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldID="hdnIncludeSelectAllOption"runat="server"Value="false"/>
- <asp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldID="hdnSelectAllText"runat="server"Value="All"/>
- <asp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldID="hdnEnableFiltering"runat="server"Value="False"/>
- <asp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldID="hdnEnableFilteringIgnoreCase"runat="server"Value="False"/>
- <asp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldID="hdnDisableIfEmpty"runat="server"Value="False"/>
- <asp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldID="hdnMaxHeight"runat="server"Value="200"/>
- <asp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldID="hdnFilterPlaceholder"runat="server"Value="Search for something..."/>
- <asp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldID="hdnAllSelectedText"runat="server"Value="No option left..."/>
- <asp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldID="hdnText"runat="server"/>
- <asp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldID="hdnValue"runat="server"/>
- <asp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldIDasp:HiddenFieldID="hdnSelectionMode"runat="server"Value="checkbox"/>
- <asp:ListBoxIDasp:ListBoxIDasp:ListBoxIDasp:ListBoxIDasp:ListBoxIDasp:ListBoxIDasp:ListBoxIDasp:ListBoxID="ddlAutoCompleteSelect"runat="server"Style="width: 350px;"
- SelectionMode="Multiple"OnSelectedIndexChanged="ddlAutoCompleteSelect_SelectedIndexChanged1">
- </asp:ListBox>
-
- <asp:RequiredFieldValidatorIDasp:RequiredFieldValidatorIDasp:RequiredFieldValidatorIDasp:RequiredFieldValidatorIDasp:RequiredFieldValidatorIDasp:RequiredFieldValidatorIDasp:RequiredFieldValidatorIDasp:RequiredFieldValidatorID="reqddlAutoCompleteSelect"runat="server"ControlToValidate="ddlAutoCompleteSelect"
- InitialValue=""Display="Dynamic"Enabled="False"ForeColor="Red">
- </asp:RequiredFieldValidator>
- <p>
- <asp:LabelIDasp:LabelIDasp:LabelIDasp:LabelIDasp:LabelIDasp:LabelIDasp:LabelIDasp:LabelID="lblSelectedItems"runat="server"Style="word-wrap: break-word; height: auto; float: left; overflow-y: auto; display: none;">
- </asp:Label>
- </p>
- </div>
AutoCompleteDdl.aspx.cs- using System;
- usingSystem.Collections.Generic;
- usingSystem.Linq;
- usingSystem.Web;
- usingSystem.Web.UI;
- usingSystem.Web.UI.WebControls;
-
- publicpartialclassUser_Control_AutoCompleteDdl: System.Web.UI.UserControl {#region Variable Declarations
-
- privateconststring _dataTextField = "Text";
- privateconststring _dataValueField = "Value";
- publiceventEventHandlerSelectedIndexChanged;
-
- #endregion
-
- #region Properties
-
- #regionBootStrap Properties
-
-
-
-
- publicstringNonSelectedText
- {
- get
- {
- returnhdnNonSelectedText.Value;
- }
- set
- {
- hdnNonSelectedText.Value = value;
- }
- }
-
-
-
-
- publicboolIncludeSelectAllOption
- {
- get
- {
- returnConvert.ToBoolean(hdnIncludeSelectAllOption.Value);
- }
- set
- {
-
-
- if (value == true && SelectionMode == ListSelectionMode.Single) {
- hdnIncludeSelectAllOption.Value = "false";
- }
- else
- {
- hdnIncludeSelectAllOption.Value = Convert.ToString(value);
- }
- }
- }
-
-
-
-
- publicboolEnableFiltering
- {
- get
- {
- returnConvert.ToBoolean(hdnEnableFiltering.Value);
- }
- set
- {
- hdnEnableFiltering.Value = Convert.ToString(value);
- }
- }
-
-
-
-
- publicstringButtonWidth
- {
- get
- {
- returnhdnButtonWidth.Value;
- }
- set
- {
- hdnButtonWidth.Value = value;
- lblSelectedItems.Style.Add("width", hdnButtonWidth.Value);
- }
- }
-
-
-
-
- publicboolDisableIfEmpty
- {
- get
- {
- returnConvert.ToBoolean(hdnDisableIfEmpty.Value);
- }
- set
- {
- hdnDisableIfEmpty.Value = Convert.ToString(value);
- }
- }
-
-
-
-
- publicintMaxHeight
- {
- get
- {
- returnConvert.ToInt32(hdnMaxHeight.Value);
- }
- set
- {
- hdnMaxHeight.Value = Convert.ToString(value);
- }
- }
-
-
-
-
- publicstringSelectAllText
- {
- get
- {
- returnhdnSelectAllText.Value;
- }
- set
- {
- hdnSelectAllText.Value = value;
- }
- }
-
-
-
-
- publicboolEnableFilteringIgnoreCase
- {
- get
- {
- returnConvert.ToBoolean(hdnEnableFilteringIgnoreCase.Value);
- }
- set
- {
- hdnEnableFilteringIgnoreCase.Value = Convert.ToString(value);
- }
- }
-
- publicstringFilterPlaceholder
- {
- get
- {
- returnhdnFilterPlaceholder.Value;
- }
- set
- {
- hdnFilterPlaceholder.Value = value;
- }
- }
-
-
- #endregion
-
- #regionListView Properties
-
- publicstringGetID
- {
- get
- {
- returnthis.ID;
- }
- }
-
- publicstringGetClientID
- {
- get
- {
- returnthis.ClientID + "_ddlAutoCompleteSelect";
- }
- }
-
-
-
-
- publicbool Enabled
- {
- get
- {
- returnddlAutoCompleteSelect.Enabled;
- }
- set
- {
- ddlAutoCompleteSelect.Enabled = value;
- }
- }
-
-
-
-
- publicListSelectionModeSelectionMode
- {
- get
- {
- returnddlAutoCompleteSelect.SelectionMode;
- }
- set
- {
- if (value == ListSelectionMode.Single)
- {
- ddlAutoCompleteSelect.SelectionMode = ListSelectionMode.Single;
- hdnSelectionMode.Value = "radio";
- }
- else
- {
- ddlAutoCompleteSelect.SelectionMode = ListSelectionMode.Multiple;
- hdnSelectionMode.Value = "checkbox";
- }
- }
- }
-
-
-
-
- publicList < SelectModel > DataSource
- {
- set
- {
- ddlAutoCompleteSelect.DataSource = value;
- ddlAutoCompleteSelect.DataBind();
- }
- }
-
-
-
-
- publicstringDataTextField
- {
- get
- {
- returnddlAutoCompleteSelect.DataTextField;
- }
-
-
-
- set
- {
- ddlAutoCompleteSelect.DataTextField = _dataTextField;
- }
- }
-
-
-
-
- publicstringDataValueField
- {
- get
- {
- returnddlAutoCompleteSelect.DataValueField;
- }
-
-
-
- set
- {
- ddlAutoCompleteSelect.DataValueField = _dataValueField;
- }
- }
-
-
-
-
- publicstring Value
- {
- get
- {
- returnhdnValue.Value;
- }
- }
-
-
-
-
- publicstring Text
- {
- get
- {
- returnhdnText.Value;
- }
- }
-
-
-
-
- publicboolAutoPostBack
- {
- get
- {
- returnddlAutoCompleteSelect.AutoPostBack;
- }
- set
- {
- ddlAutoCompleteSelect.AutoPostBack = value;
- }
- }
-
-
-
-
- publicListItemCollection Items
- {
- get
- {
- returnddlAutoCompleteSelect.Items;
- }
- }
-
-
-
-
- publicintSelectedIndex
- {
- get
- {
- returnddlAutoCompleteSelect.SelectedIndex;
- }
- set
- {
- ddlAutoCompleteSelect.SelectedIndex = value;
- }
- }
-
- publicListItemSelectedItem
- {
- get
- {
- returnddlAutoCompleteSelect.SelectedItem;
- }
- }
-
-
-
- publicstringSelectedValue
- {
- get
- {
- returnddlAutoCompleteSelect.SelectedValue;
- }
- set
- {
- if ((ddlAutoCompleteSelect.Items.Count > 0 && !value.Equals("0") && !value.Equals("")))
- {
- ddlAutoCompleteSelect.SelectedValue = value;
- }
- }
- }
-
-
-
-
- publicstringErrorMessage
- {
- get
- {
- returnreqddlAutoCompleteSelect.ErrorMessage;
- }
- set
- {
- reqddlAutoCompleteSelect.ErrorMessage = value;
- }
- }
-
- publicboolEnableValidation
- {
- get
- {
- returnddlAutoCompleteSelect.CausesValidation;
- }
- set
- {
- reqddlAutoCompleteSelect.Enabled = value;
- ddlAutoCompleteSelect.CausesValidation = value;
- }
- }
-
- publicstringRequiredFieldValidationGroup
- {
- get
- {
- returnreqddlAutoCompleteSelect.ValidationGroup;
- }
-
- set
- {
- reqddlAutoCompleteSelect.ValidationGroup = value;
- }
- }
-
- publicstringDropDownValidationGroup
- {
- get
- {
- returnddlAutoCompleteSelect.ValidationGroup;
- }
- set
- {
- ddlAutoCompleteSelect.ValidationGroup = value;
- }
- }
-
- #endregion
-
- #endregion
-
- #region Page Events
-
- protectedvoidPage_Load(object sender, System.EventArgs e)
- {
- try
- {
- if (!(string.IsNullOrEmpty(hdnText.Value) && string.IsNullOrEmpty(hdnValue.Value)))
- {
- string[] selectedItemsText = hdnText.Value.Split(newchar[]
- {
- ','
- }, StringSplitOptions.RemoveEmptyEntries);
- string[] selectedItemsValue = hdnValue.Value.Split(newchar[]
- {
- ','
- }, StringSplitOptions.RemoveEmptyEntries);
-
- IEnumerable < ListItem > listItems = ddlAutoCompleteSelect.Items.Cast < ListItem > ().Where(x => selectedItemsText.Contains(x.Text) && selectedItemsValue.Contains(x.Value));
-
- foreach(ListItem item inlistItems)
- {
- item.Selected = true;
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
-
- protectedvoidPage_PreRender(object sender, System.EventArgs e)
- {
- try
- {
-
- ScriptManager.RegisterClientScriptInclude(this, this.GetType(), "bootStrapJs", ResolveUrl("~/Scripts/bootstrap.min.js"));
- ScriptManager.RegisterClientScriptInclude(this, this.GetType(), "bootStrapMultiSelectJs", ResolveUrl("~/Scripts/bootstrap-multiselect.js"));
- ScriptManager.RegisterClientScriptInclude(this, this.GetType(), "autoCompleteDdlJs", ResolveUrl("~/Scripts/app/AutoCompleteDdl.js"));
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
-
- protectedvoid ddlAutoCompleteSelect_SelectedIndexChanged1(object sender, EventArgs e)
- {
- if (SelectedIndexChanged != null)
- {
- SelectedIndexChanged(sender, e);
- }
- }
-
- #endregion
-
- }
AutoCompleteDdl.js
-
-
-
- varhdnButtonWidth = '';
- varhdnNonSelectedText = '';
- varhdnIncludeSelectAllOption = '';
- varhdnSelectAllText = '';
- varhdnEnableFiltering = '';
- varhdnEnableFilteringIgnoreCase = '';
- varhdnDisableIfEmpty = '';
- varhdnMaxHeight = '';
- varhdnFilterPlaceholder = '';
- varhdnAllSelectedText = '';
- varhdnSelectionMode = '';
-
- varpostBackElementID = '';
-
-
- varlabelId = '';
- varhdnTextId = '';
- varhdnValueId = '';
- varucParentDiv = '';
-
-
- varselectedItemsText = '';
- varselectedItemsValue = '';
-
-
-
- functionconvertToBoolean(value)
- {
- return (value === "true");
- }
-
- functionpageLoad()
- {
-
- $(document).ready(function()
- {
-
- Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(InitializeRequestHandler);
- functionInitializeRequestHandler(sender, args)
- {
- postBackElementID = args.get_postBackElement().id;
- }
-
-
- varmultiSelectFunction = $.fn.multiselect.Constructor;
-
-
- multiSelectFunction.prototype.updateButtonText = function() {
-
- selectedItemsText = '';
- selectedItemsValue = '';
-
-
- var options = this.getSelected();
-
- varinputType = this.options.multiple ? "checkbox" : "radio";
-
-
- if (this.options.enableHTML)
- {
- $('.multiselect .multiselect-selected-text', this.$container).html(hdnNonSelectedText);
- }
- else
- {
- $('.multiselect .multiselect-selected-text', this.$container).text(hdnNonSelectedText);
- }
-
-
- ucParentDiv = this.$container.parent();
-
-
- $('.multiselect', this.$container).attr('title', hdnNonSelectedText);
-
-
- if (options.length > 0)
- {
- if (inputType === "checkbox")
- {
- varliSelectedItems = this.options.buttonText(options, this.$select);
-
-
- labelId = $(ucParentDiv).find("[id*='lblSelectedItems']");
- hdnTextId = $(ucParentDiv).find("[id*='hdnText']");
- hdnValueId = $(ucParentDiv).find("[id*='hdnValue']");
-
-
- $(labelId).css("display", "");
-
- $(labelId).html("<ul>" + liSelectedItems + "</ul>");
-
-
- $.each(options, function(index, option)
- {
- selectedItemsText += option.text + ",";
- selectedItemsValue += option.value + ",";
- });
-
-
- selectedItemsText = selectedItemsText.substring(0, selectedItemsText.lastIndexOf(","));
- selectedItemsValue = selectedItemsValue.substring(0, selectedItemsValue.lastIndexOf(","));
-
- }
- else
- {
-
-
- varselectedOption = this.options.buttonText(options, this.$select);
-
- if (this.options.enableHTML)
- {
- $('.multiselect .multiselect-selected-text', this.$container).html(selectedOption);
- }
- else
- {
- $('.multiselect .multiselect-selected-text', this.$container).text(selectedOption);
- }
-
- $('.multiselect', this.$container).attr('title', selectedOption);
-
- labelId = $(ucParentDiv).find("[id*='lblSelectedItems']");
- hdnTextId = $(ucParentDiv).find("[id*='hdnText']");
- hdnValueId = $(ucParentDiv).find("[id*='hdnValue']");
-
-
- $(labelId).html("");
-
- $(labelId).css("display", "none");
-
- selectedItemsText = options.text();
- selectedItemsValue = options.val();
- }
- }
-
-
- $(hdnTextId).val(selectedItemsText);
- $(hdnValueId).val(selectedItemsValue);
- }
-
-
-
- $("select[id*='ddlAutoCompleteSelect']").each(function()
- {
- varddlCntrl = $(this);
-
- vardivUCParent = $(ddlCntrl).parent();
-
-
- hdnButtonWidth = $("#" + ddlCntrl.attr("id").replace("ddlAutoCompleteSelect", "hdnButtonWidth")).val();
- hdnNonSelectedText = $("#" + ddlCntrl.attr("id").replace("ddlAutoCompleteSelect", "hdnNonSelectedText")).val();
- hdnIncludeSelectAllOption = convertToBoolean($("#" + ddlCntrl.attr("id").replace("ddlAutoCompleteSelect", "hdnIncludeSelectAllOption")).val().toString().toLowerCase());
- hdnSelectAllText = $("#" + ddlCntrl.attr("id").replace("ddlAutoCompleteSelect", "hdnSelectAllText")).val();
- hdnEnableFiltering = convertToBoolean($("#" + ddlCntrl.attr("id").replace("ddlAutoCompleteSelect", "hdnEnableFiltering")).val().toString().toLowerCase());
- hdnEnableFilteringIgnoreCase = convertToBoolean($("#" + ddlCntrl.attr("id").replace("ddlAutoCompleteSelect", "hdnEnableFilteringIgnoreCase")).val().toString().toLowerCase());
- hdnDisableIfEmpty = convertToBoolean($("#" + ddlCntrl.attr("id").replace("ddlAutoCompleteSelect", "hdnDisableIfEmpty")).val().toString().toLowerCase());
- hdnMaxHeight = $("#" + ddlCntrl.attr("id").replace("ddlAutoCompleteSelect", "hdnMaxHeight")).val();
- hdnFilterPlaceholder = $("#" + ddlCntrl.attr("id").replace("ddlAutoCompleteSelect", "hdnFilterPlaceholder")).val();
- hdnAllSelectedText = $("#" + ddlCntrl.attr("id").replace("ddlAutoCompleteSelect", "hdnAllSelectedText")).val();
- hdnSelectionMode = $("#" + ddlCntrl.attr("id").replace("ddlAutoCompleteSelect", "hdnSelectionMode")).val();
-
-
- varinputType = hdnSelectionMode;
-
-
- $(this).multiselect({
- buttonWidth: hdnButtonWidth,
- includeSelectAllOption: hdnIncludeSelectAllOption,
- enableFiltering: hdnEnableFiltering,
- enableCaseInsensitiveFiltering: hdnEnableFilteringIgnoreCase,
- selectAllText: hdnSelectAllText,
- nonSelectedText: hdnNonSelectedText,
- disableIfEmpty: hdnDisableIfEmpty,
- maxHeight: hdnMaxHeight,
- filterPlaceholder: hdnFilterPlaceholder,
- allSelectedText: hdnAllSelectedText,
- buttonText: function(options, select)
- {
- if (options.length === 0)
- {
- returnthis.nonSelectedText;
- }
- else
- {
- var selected = '';
-
- if (inputType === "checkbox")
- {
- options.each(function()
- {
- var label = ($(this).attr('label') !== undefined) ? $(this).attr('label') : $(this).text();
- selected += "<li>" + label + "</li>";
- });
- }
- else
- {
-
- selected = options.text();
- }
- return selected;
- }
- }
- });
-
-
- if (inputType === "checkbox")
- {
- if (postBackElementID == $(this).attr("id"))
- {
-
- vardivButtonGroup = $("#" + divUCParent.attr("id")).find(".btn-group");
- $(divButtonGroup).addClass("open");
- }
- }
- });
- });
- }
Default.aspx Default.aspx.cs- using System;
- usingSystem.Collections.Generic;
- usingSystem.Linq;
- usingSystem.Web;
- usingSystem.Web.UI;
- usingSystem.Web.UI.WebControls;
-
- publicpartialclass_Default: System.Web.UI.Page
- {
- List < SelectModel > lstData = newList < SelectModel > ();
- List < SelectModel > lstDependent = newList < SelectModel > ();
-
- protectedvoidPage_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- LoadData();
- LoadSingleSelectData();
- LoadMultiSelectData();
- LoadPrimaryMultiSelect();
- }
- ddlPrimaryMultiSelect.SelectedIndexChanged += ddlPrimaryMultiSelect_SelectedIndexChanged;
- }
-
- publicvoidddlPrimaryMultiSelect_SelectedIndexChanged(object sender, EventArgs e) {
- LoadDependentDDL();
- }
-
- privatevoidLoadData()
- {
- for (inti = 0; i < 5; i++)
- {
- lstData.Add(newSelectModel()
- {
- Value = "Item " + i, Text = "Item " + i
- });
- }
- }
-
- privatevoidLoadSingleSelectData()
- {
- ddlSingleSelect.DataValueField = "Value";
- ddlSingleSelect.DataTextField = "Text";
-
- ddlSingleSelect.DataSource = lstData;
- }
-
- privatevoidLoadMultiSelectData()
- {
- ddlMultiSelect.DataValueField = "Value";
- ddlMultiSelect.DataTextField = "Text";
- ddlMultiSelect.DataSource = lstData;
- }
-
- privatevoidLoadPrimaryMultiSelect()
- {
- ddlPrimaryMultiSelect.DataValueField = "Value";
- ddlPrimaryMultiSelect.DataTextField = "Text";
- ddlPrimaryMultiSelect.DataSource = lstData;
- }
-
- privatevoidLoadDependentDDL()
- {
- stringselectedItem = ddlPrimaryMultiSelect.SelectedItem.Text;
- stringsubItem = "Sub " + selectedItem;
- lstDependent.Clear();
- lstDependent.Add(newSelectModel()
- {
- Text = subItem, Value = subItem
- });
- ddlDependent.DataValueField = "Value";
- ddlDependent.DataTextField = "Text";
- ddlDependent.DataSource = lstDependent;
- ddlDependent.DataBind();
- }
-
- protectedvoidbtnSingleSelect_Click(object sender, EventArgs e) {
- string value = ddlSingleSelect.Value;
- string text = ddlSingleSelect.Text;
-
- lblSingleSelectData.Text = "<b>Value: </b>" + value + "<br/><b>Text: </b>" + text;
- }
-
- protectedvoidbtnMultiSelect_Click(object sender, EventArgs e)
- {
- string value = ddlMultiSelect.Value;
- string text = ddlMultiSelect.Text;
-
- lblMultiSelectData.Text = "<b>Value: </b>" + value + "<br/><b>Text: </b>" + text;
- }
-
- }
Now let’s run the application and you’ll see the following output.
Figure 1: Output