Click here to Skip to main content
15,910,009 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

Here i have ajax enabled combobox in asp.net.I have populated this combobox using sql server database.Now problem is that when i am goind to search or suggest input to combobox then it search only from start index.I want to search any where in string
for eg.
when i type test then combobox must have to show all string those contains test word.

What I have tried:

This is my design page code
  <asp:ScriptManager ID="ScriptManager1" runat="server">
  </asp:ScriptManager>
<cc1:ComboBox ID="cmbLocationList" runat="server" Width="200PX"
      AutoPostBack="true"  AutoCompleteMode="SuggestAppend"
    >
  </cc1:ComboBox>
Posted
Updated 27-Oct-17 23:08pm
Comments
Karthik_Mahalingam 27-Oct-17 5:40am    
show the code of the Combobox user control ?
you will have to add like condition in the query.
SujataJK 27-Oct-17 7:59am    
In my code combobox is bind in page_load().

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadLocationList();
}

}

private void LoadLocationList()
{
SqlConnection con = null;
SqlCommand cmd = null; ;
SqlDataReader dr;
try
{
con = new SqlConnection(ConfigurationManager.ConnectionStrings["CRMConnection"].ConnectionString);

cmd = new SqlCommand("select locationname from dbo.tbl_LocationMaster");
con.Open();
cmd.Connection = con;
SqlDataAdapter ad = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ad.Fill(ds);
//dr = cmd.ExecuteReader();
if (ds.Tables[0].Rows.Count > 0)
{

cmbLocationList.DataSource = ds;
cmbLocationList.DataBind();
cmbLocationList.DataTextField = "locationname";
cmbLocationList.DataValueField = "locationname";
cmbLocationList.DataBind();
cmbLocationList.Items.Insert(0, new ListItem(" ", ""));
}
else
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Message", "alert('No Data Found')", true);
}
}
catch (Exception ex)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Message", "alert('" + ex.Message + "')", true);
}
finally
{
cmd.Dispose();
con.Close();
}

}
Karthik_Mahalingam 27-Oct-17 8:00am    
Do you have the code for user control?
SujataJK 27-Oct-17 8:17am    
actually i am new to this concept.i have not added any user control.Please guide me how to use this.
Karthik_Mahalingam 27-Oct-17 8:22am    
cc1:ComboBox

It's an user control or ajaxtoolkit control?

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900