Click here to Skip to main content
15,915,000 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i am doing search through using ajax autocomplete in that i got one dropdown..I want to pass selected value of dropdown to a webservice..here my code is..plz anyone help regard this issue

C#
public string[] GetCountry(string prefixText)
 {

     //Retieve connection string from config file and assigned in to the sqlconnection
     SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
     SqlCommand sqlcmd = new SqlCommand();
     DataSet ds = new DataSet();
     //write query to get country name based on user entered text
     string query = "select  Name from hospital_hospitaladd where Name like '" + prefixText + "%' ";
     sqlcmd = new SqlCommand(query, sqlcon);
     sqlcon.Open();
     SqlDataAdapter da = new SqlDataAdapter();
     da.SelectCommand = sqlcmd;
     da.Fill(ds);
     //Create one array variable and set size based on return datatable row count
     string[] cname = new string[ds.Tables[0].Rows.Count];
     //string[] category = new string[ds.Tables[0].Rows.Count];
     int i = 0;
     try
     {
         foreach (DataRow dr in ds.Tables[0].Rows)
         {
             //assign each value in to the array variable
             cname.SetValue(dr["Name"].ToString(), i);
             //cname.SetValue(dr["category"].ToString(), i);
             i++;
         }
     }
     catch (Exception ex)
     {
     }
     finally
     {
         sqlcon.Close();
     }
     //Lastreturn that array values for bind in extender
     return cname;
 }


regards,
Manohar
Posted
Updated 27-Jun-12 2:20am
v2
Comments
ZurdoDev 27-Jun-12 8:20am    
EDIT: added code tags
ZurdoDev 27-Jun-12 8:20am    
So, what exactly is the question?
CodingLover 29-Jun-12 9:19am    
Dropdown always select one value. So all you want to do is pass that value, as you said. But how, may be a user event?

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