Multi column Rad Combo Filter

3 posts, 0 answers
  1. Prassin
    Prassin avatar
    87 posts
    Member since:
    Jun 2012

    Posted 25 Jul 2012 Link to this post

    Hi all,

    I have a multi column rad combo box, and the combo box having two columns. when i try to use the combo box filter that time i need to work that filter on that two columns at a time. how can i achieve this.. 
    Please help..


    Regards,

    Prassin
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Jul 2012 Link to this post

    Hi Prassin,

    I suppose you want to achieve filtering in RadComboBox based on two columns. Following is the sample code that I tried.

    ASPX:
    <telerik:RadComboBox runat="server" ID="RadComboBox1" Height="190px" Width="420px" MarkFirstMatch="true" DataSourceID="SqlDataSource1" EnableLoadOnDemand="true"  OnItemDataBound="RadComboBox1_ItemDataBound" HighlightTemplatedItems="true" OnItemsRequested="RadComboBox1_ItemsRequested">
      <HeaderTemplate>
        <ul>
          <li class="col1">Contact Name</li>
          <li class="col2">City</li>
        </ul>
      </HeaderTemplate>
      <ItemTemplate>
        <ul>
          <li class="col1"><%# DataBinder.Eval(Container.DataItem, "ContactName") %></li>
          <li class="col2"><%# DataBinder.Eval(Container.DataItem, "City") %></li>
        </ul>
      </ItemTemplate>
    </telerik:RadComboBox>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT * FROM [Customers]"></asp:SqlDataSource>

    C#:
    protected void RadComboBox1_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
      {
        string sql = "SELECT * from Customers WHERE ContactName LIKE '" + e.Text + "%' OR City LIKE'" + e.Text + "%'";
        SqlDataSource1.SelectCommand = sql;
        RadComboBox1.DataBind();
      }
    protected void RadComboBox1_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
      {
        e.Item.Text = ((DataRowView)e.Item.DataItem)["ContactName"].ToString();
        e.Item.Value = ((DataRowView)e.Item.DataItem)["CustomerID"].ToString();
      }

    Hope this helps.

    Regards,
    Princy.
  3. Prassin
    Prassin avatar
    87 posts
    Member since:
    Jun 2012

    Posted 25 Jul 2012 Link to this post

    Hi Princy,

    Thanks for the valuable replay,, 

    the code working fine... but i wish to know is there any client side code to achieve this goal.. the combo populated by form load event.. 
    please replay if any..

    Regards 

    Prassin 
Back to Top