User107

User107

  • 1.9k
  • 29
  • 9.8k

change DropDownCheckboxes property SelectBoxCaption dynamic

Sep 20 2016 8:09 AM

When user select multiple values from DropDownCheckboxes, and How can you show the selected values at the SelectBoxCaption.

How can i do it.

my .aspx code:

<%@ Register Namespace="Saplin.Controls" Assembly="DropDownCheckBoxes" TagPrefix="asp"%> 
<asp:DropDownCheckBoxes ID="dropdown1" runat="server" UseSelectAllNode="true"
UseButtons="true" OnSelectedIndexChanged="dropdown1_SelectedIndexChanged"
AutoPostBack="true"><Style DropDownBoxBoxWidth="200"/> </asp:DropDownCheckBoxes>

.cs

protected void dropdown1_SelectedIndexChanged(object sender, EventArgs e)
 {
 List<String> checkedList = new List<string>();
 foreach (ListItem item in dropdown1.Items)
 {
if (item.Selected)
 {
checkedList
.Add(item.Text);
 }
}
dropdown1
.Texts.SelectBoxCaption = String.Join(",", checkedList);
}

Can anyone help me

Thank you



Answers (1)