Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

How to select a value from CSV in an asp.net ajax toolbox autocomplete and pass that value to other textboxes?

$
0
0
I have used Ajax toolkit autocomplete working fine using the following asp.net and C# code.<asp:UpdatePanel ID="updPnlMedicineName" runat="server" ><ContentTemplate> Name<br /><asp:TextBox ID="txtMedName" runat="server" Width="150px" ontextchanged="txtMedName_TextChanged"></TextBox><cc1:AutoCompleteExtender ID="txtSearchID_AutoCompleteExtender" runat="server"
DelimiterCharacters="" OnClientItemSelected="ItemSelected" Enabled="True" GetMedicine"
 ServicePath="Search/NameSearch.asmx" TargetControlID="txtMedName" MinimumPrefixLength="1"></cc1:AutoCompleteExtender>
My code Behind is :
[WebMethod]
public string[] GetMedicine(string prefixText)
{
 List<string> listString = new List<string>();
 using (SqlConnection con = new  SqlConnection(ConfigurationManager.ConnectionStrings["NewLandConnectionString"].ConnectionString))
{
 SqlCommand com = new SqlCommand("select ProductName+','+ProductCode+',' + (select unitName from Unit where Unit.Id=product1.UnitId) as ProductDetails,ProductId from product1 where ProductName like '"+prefixText+"%'", con);
 con.Open();
 SqlDataAdapter adr = new SqlDataAdapter(com);
 DataTable dt = new DataTable();
 adr.Fill(dt);
  for (int j = 0; j < dt.Rows.Count; j++)
        {
            string countProduct = dt.Rows[j]["ProductDetails"].ToString();

           listString.Add(AutoCompleteExtender.CreateAutoCompleteItem(dt.Rows[j]["ProductDetails"].ToString(),dt.Rows[j]["ProductId"].ToString()));
        }
  }
    string[] strarray = listString.ToArray();
    return strarray;
 }

Now when my auto complete works i get values in the form of : somename,code,unit but i want that if a value is selected then i must get only the first value from csv i.e "somename" in that texbox and other two values(i.e code,unit ) must be populated in other texboxes respectively.

Please, help me in achieving this task.

Thanks in advance !!


Viewing all articles
Browse latest Browse all 5678

Latest Images

Trending Articles



Latest Images