This is a migrated thread and some comments may be shown as answers.

Multi column Rad Combo Filter

2 Answers 71 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Prassin
Top achievements
Rank 1
Prassin asked on 25 Jul 2012, 06:55 AM
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 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 25 Jul 2012, 09:25 AM
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.
0
Prassin
Top achievements
Rank 1
answered on 25 Jul 2012, 09:55 AM
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 
Tags
ComboBox
Asked by
Prassin
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Prassin
Top achievements
Rank 1
Share this question
or