We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Setting selecteditems on serverside

I have a Multiselectiondropdown control binded to a datatable, on the page load I want to be able to pre select values in this control. My code currently seems to do this successfully on the server side however the selecteditems do not appear in the control on the client side. see code snippets below. probably something simple I am not doing but can't see it myself!
 
c#
following code is in page_load within a if (!Page.IsPostBack) check...

DataTable dtMP = PortalData.GetTableData("tsResults", strFilterCriteria + " GROUP BY TradeSite");
msddfMP.DataSource = dtMP;
msddfMP.DataTextField = "TradeSite";
msddfMP.DataValueField = "TradeSite";
msddfMP.DataBind();
msddfMP.CheckBoxListRepeatColumns = 4;
msddfMP.CheckBoxListRepeatDirection = RepeatDirection.Vertical;
msddfMP.PopupPositionVertical = Syncfusion.Web.UI.WebControls.Shared.PopupPositionVertical.Bottom;
foreach (string theMarketplace in PortalData.getCountryMarketplaces(theFilterValue))
{
     ListItem theItem = msddfMP.Items.FindByText(theMarketplace);
     if (theItem != null)
     {
         theItem.Selected = true;
         msddfMP.SelectedItems.Add(theItem);
     }
}
msddfMP.UpdateText();
UpdatePanel15.Update(); //Display selected trade sites for country
.aspx
 
<asp:UpdatePanel ID="UpdatePanel15" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<syncfusion:MultiSelectionDropDown ID="msddfMP"
  TextBoxCssClass="form-control input-sm"
  ButtonCssClass="form-control input-sm"
  ButtonHoverCssClass="form-control input-sm"
  TextBoxHoverCssClass="form-control input-sm"
  runat="server" Width="100%" >
</syncfusion:MultiSelectionDropDown>
</ContentTemplate>
  <Triggers>
    <asp:AsyncPostBackTrigger ControlID="btnClear" EventName="Click"  />
  </Triggers>
</asp:UpdatePanel>
 

1 Reply

ES Ezhil S Syncfusion Team April 3, 2015 02:43 PM UTC

Hi Gardner,

Thank you for contacting Syncfusion support.

With reference to the shared code snippet, We are unable to reproduce the reported issue on not displaying the dynamically selected items in MultiSelectDropDown control from code behind. We have prepared sample with the shared code using dummy database and that works fine at our end. Could you please share us defect sample or modify ur sample to issue at our end? So that we can provide you a solution.

We have prepared a simple sample and it can be downloaded from link below:
http://www.syncfusion.com/downloads/support/forum/118700/MultiSelect_f118700_(3)1794106504.zip
Please let us know if you have any other queries.

Regards,
Ezhil S

Loader.
Up arrow icon