none
Ajax autocomplete extender ve table dan veri gösterme ? RRS feed

  • Soru

  • Merhaba

    Aşağıdaki kodları nasıl birleştirebilirim. Ajax eklediğim textbox sadece aşağıdaki örnekteki string veriyi gösteriyor. Fakat ben table dan veri çekerek göstermek isityorum. Ne yapmam gerekiyor ?

    System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()] 
        public static string[] GetCompletionList2(string prefixText, int count, string contextKey) 
        { 
            // Create array of movies 
            string[] movies = { "Star Wars", "Star Trek", "Star Trek", "Star Trek", "Star Trek", "Star Trek", "Star Trek", "Star Trek", "Star Trek", "Star Trek", "Star Trek", "Star Trek", "Superman", "Memento", "Shrek", "Shrek II" }; 
     
            // Return matching movies 
            return (from m in movies where m.StartsWith(prefixText, StringComparison.CurrentCultureIgnoreCase) select m).Take(count).ToArray(); 
        } 
    void records() 
    { 
     SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()); 
            if (cn.State != System.Data.ConnectionState.Open) 
            { 
                cn.Open(); 
            } 
            SqlCommand cmd = new SqlCommand("kayitcek", cn); 
            cmd.CommandType = CommandType.StoredProcedure; 
                    SqlParameter id113 = cmd.Parameters.Add("@txt", SqlDbType.VarChar, 100); 
            id113.Direction = ParameterDirection.Input; 
            id113.Value = txtMovie.Text; 
            SqlDataAdapter da = new SqlDataAdapter(cmd); 
            DataTable dt = new DataTable(); 
            da.Fill(dt); 
    cn.Close(); 
    }

    4 Nisan 2013 Perşembe 13:51

Yanıtlar

  • [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()] 
        public static string[] GetCompletionList2(string prefixText, int count, string contextKey) 
        { 
     SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()); 
            if (cn.State != System.Data.ConnectionState.Open) 
            { 
                cn.Open(); 
            } 
            SqlCommand cmd = new SqlCommand("kayitcek", cn); 
            cmd.CommandType = CommandType.StoredProcedure; 
                    SqlParameter id113 = cmd.Parameters.Add("@txt", SqlDbType.VarChar, 100); 
            id113.Direction = ParameterDirection.Input; 
            id113.Value = txtMovie.Text; 
            SqlDataAdapter da = new SqlDataAdapter(cmd); 
            DataTable dt = new DataTable(); 
            da.Fill(dt); 
    cn.Close(); 
            
            return dt.Rows.Cast<DataRow>().Select<string>(p => new { p["alan_adını_yaz"].ToString() }).ToArray();
    }
    şeklinde denermisin...

    e-mail: onay[nokta]yalciner[at]hotmail[nokta]com
    MCC

    4 Nisan 2013 Perşembe 14:49
    Moderatör