Hi Mikhail,
this works fine to copy the article number also in the textbox for the description.
But I need to copy an other value to it, one textbox should holt the article number and the other one the article description.
Do you have also a solution for?
I post my code behind to explain the maining of:
Code:
[WebMethod]
[ScriptMethod]
public string ArtNrSuggest(string tryValue, string[] additionalParams) {
List<SuggestionItem> items = new List<SuggestionItem>();
string FindWhat = tryValue;
OleDbConnection con = new OleDbConnection(GetConnectionString());
con.Open();
OleDbCommand cmd = new OleDbCommand(String.Format("SELECT TOP 20 ID, Artikelnummer FROM Artikel WHERE Artikelnummer LIKE '%{0}%'",FindWhat), con);
OleDbDataReader Sdr = cmd.ExecuteReader();
while (Sdr.Read())
{
//parce data from DataReader
string art = string.Empty;
string id = string.Empty;
if (Sdr["Artikelnummer"] != null && Sdr["Artikelnummer"] != DBNull.Value)
{
art = Sdr["Artikelnummer"].ToString();
}
if (Sdr["ID"] != null && Sdr["ID"] != DBNull.Value)
{
id = Sdr["ID"].ToString();
}
//create SuggestionItem
SuggestionItem suggestionItem = new SuggestionItem();
suggestionItem.Title = art;
suggestionItem.Id = id;
//add item to the list
items.Add(suggestionItem);
}
con.Close();
//create result Item
SuggestionResult suggestionResult = new SuggestionResult();
suggestionResult.Items = items.ToArray();
suggestionResult.Header = new BasicSuggestionTemplate("Vorschläge zu Ihrer Suche:");
// suggestionResult.Footer = new BasicSuggestionTemplate("Powered by ConvincingMail");
return suggestionResult.ToJSON(tryValue);
}
[WebMethod]
[ScriptMethod]
public string ArtNameSuggest(string tryValue, string[] additionalParams)
{
List<SuggestionItem> items = new List<SuggestionItem>();
string FindWhat = tryValue;
OleDbConnection con = new OleDbConnection(GetConnectionString());
con.Open();
OleDbCommand cmd = new OleDbCommand(String.Format("SELECT TOP 20 ID, Bezeichnung FROM Artikel WHERE Bezeichnung LIKE '{0}%'", FindWhat), con);
OleDbDataReader Sdr = cmd.ExecuteReader();
while (Sdr.Read())
{
//parce data from DataReader
string art = string.Empty;
string id = string.Empty;
if (Sdr["Bezeichnung"] != null && Sdr["Bezeichnung"] != DBNull.Value)
{
art = Sdr["Bezeichnung"].ToString();
}
if (Sdr["ID"] != null && Sdr["ID"] != DBNull.Value)
{
id = Sdr["ID"].ToString();
}
//create SuggestionItem
SuggestionItem suggestionItem = new SuggestionItem();
suggestionItem.Title = art;
suggestionItem.Id = id;
//add item to the list
items.Add(suggestionItem);
}
con.Close();
//create result Item
SuggestionResult suggestionResult = new SuggestionResult();
suggestionResult.Items = items.ToArray();
suggestionResult.Header = new BasicSuggestionTemplate("Vorschläge zu Ihrer Suche:");
// suggestionResult.Footer = new BasicSuggestionTemplate("Powered by ConvincingMail");
return suggestionResult.ToJSON(tryValue);
}
So ArtNrSuggest needs a query like:
new OleDbCommand(String.Format("SELECT TOP 20 ID, Artikelnummer, Bezeichnung FROM Artikel WHERE Artikelnummer LIKE '%{0}%'",FindWhat), con);
Where the third field 'Bezeichnung' will be the description I like to use for the seccond textbox when the articel number will be changed.
Thanks,
Andre