Set "Selected Item" in multiselect RadComboBox

4 posts, 0 answers
  1. Rahul
    Rahul avatar
    7 posts
    Member since:
    Nov 2012

    Posted 17 Nov 2012 Link to this post

    Hi guys,

    Is there any way we can set Selected Items or Checked Items in a multiselect RadComboBox ?.

    I tried following code but that works only if it is not a multiselect RadComboBox.

    RadComboBox.SelectedValue = "123"

    Edit : Also I am setting value on post back in vb.net

    Thanks,
    Rahul
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Nov 2012 Link to this post

    Hi Rahul,

    I suppose you want to set the SelectedItem in a RadComboBox with CheckBoxes property is set to true. Following is the sample code that I tried to set the SelectedItem in a multiselect RadComboBox.

    ASPX:
    <telerik:RadComboBox ID="RadComboBox1" runat="server" CheckBoxes="true">
      <Items>
        ..........
      </Items>
    </telerik:RadComboBox>
    <asp:Button ID="btn" runat="server" OnClick="btn_Click" />

    VB:
    Protected Sub btn_Click(sender As Object, e As EventArgs)
        RadComboBox1.SelectedValue = "123"
        RadComboBox1.SelectedItem.Checked = True
    End Sub

    Hope this helps.

    Regards,
    Princy.
  3. Amrit
    Amrit avatar
    4 posts
    Member since:
    May 2013

    Posted 27 May 2013 Link to this post

    <

     

     

    telerik:GridTemplateColumn UniqueName="RCBTechnology" HeaderStyle-Width="200px" HeaderText="Choose Technology">

     

     

     

     

     

     

     

    <ItemTemplate>

     

     

     

    <telerik:RadComboBox runat="server" CheckBoxes="true" EnableCheckAllItemsCheckBox="true"

     

     

     

    DataSourceID="LDSPractice" DataValueField="ID" DataTextField="Technology"

     

     

     

     

     

     

     

    DropDownAutoWidth="Enabled" MarkFirstMatch="true" Height="200" EnableTextSelection="true">

     

     

     

     

     

     

     

    </telerik:RadComboBox>

     

     

     

     

     

     

     

    </ItemTemplate>

     

     

     

     

     

     

     

    </telerik:GridTemplateColumn>

     

     

     

     


     

    protected

     

     

    void GvEstimation_ItemDataBound(object sender, GridItemEventArgs e)

     

    {

     

     

     

     

     try

     

     

     

     

     {

     

     

     

        RadComboBox

     

     

    techRCB = item["RCBTechnology"].Controls[1] as RadComboBox;

     

        foreach

     

     

    (var tech in technologyList)

     

        {

        

     

    techRCB.SelectedValue = tech.ID.ToString();

     

        techRCB.SelectedItem.Checked =

     

    true;

     

        }
     }

     

     

     

     

     

     

     

     

     

    }

     

  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 May 2013 Link to this post

    Hi,

    Try the following code snippet to set selected items in a multiselect RadCombobox.

    VB:
    Protected Sub grid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
     For Each item As GridDataItem In grid1.MasterTableView.Items
      Dim RadComboBox1 As RadComboBox = DirectCast(item.FindControl("RadComboBox1"), RadComboBox)
       For index As Integer = 0 To 4
        RadComboBox1.SelectedValue =RadComboBox1.Items(index).Value
        RadComboBox1.SelectedItem.Checked = True
      Next
     Next
    End Sub

    Thanks,
    Princy.
Back to Top