Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi.. i want to use Autocomplete in a column inside datagridview ,but Autocompletemode
, AutoCompleteSource and AutoCompleteCustomSource properties are only available, not in the DataGridView.


Does anyone have an idea how to get around this? Maybe some code in the EditingControlShowing event or something?
Posted
Comments
Dean Oliver 5-Mar-12 1:02am    
is this wpf or win forms?

1 solution

Design Code
Quote:
<asp:textbox id="username" textmode="SingleLine" runat="server" xmlns:asp="#unknown">
ToolTip="Enter username" AutoCompleteType="DisplayName" Height="22px">
<ajax:autocompleteextender id="AutoCompleteExtender1" runat="server" targetcontrolid="username" xmlns:ajax="#unknown">
MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1" CompletionInterval="1000" ServiceMethod="GetCountries" >

cs code
Quote:

[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> GetCountries(string prefixText)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["schoolconn"].ToString());
con.Open();
SqlCommand cmd = new SqlCommand("select * from login_details where username like @Name+'%'", con);
cmd.Parameters.AddWithValue("@Name", prefixText);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
List<string> CountryNames = new List<string>();
for (int i = 0; i < dt.Rows.Count; i++)
{
CountryNames.Add(dt.Rows[i][2].ToString());
}
return CountryNames;
}
 
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