hi all, hope in your help.
I worked with this tutorial http://www.asp.net/ajaxlibrary/act_A...te_Simple.ashx
I've problem because when in textbox selected one value I need update the gridview but the gridview not update, can you help me?
Code:[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()] public static string[] GetCompletionList(string prefixText, int count, string contextKey) { OdbcConnection myConnectionString = new OdbcConnection(ConfigurationManager.ConnectionStrings["ConnGCCom"].ConnectionString); DataSet ds = new DataSet(); DataTable dt = new DataTable(); OdbcCommand cmd = new OdbcCommand(); cmd.Connection = myConnectionString; cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT ListNumber "; cmd.CommandText = cmd.CommandText + " FROM tbl_X "; cmd.CommandText = cmd.CommandText + " WHERE ListNumber LIKE CONCAT('%',?,'%') "; cmd.CommandText = cmd.CommandText + " GROUP BY ListNumber;"; cmd.Parameters.AddWithValue("?", prefixText); try { myConnectionString.Open(); cmd.ExecuteNonQuery(); OdbcDataAdapter da = new OdbcDataAdapter(cmd); da.Fill(ds); } catch (Exception ex) { throw new Exception(ex.Message); } finally { myConnectionString.Close(); } dt = ds.Tables[0]; List<string> txtItems = new List<string>(); String dbValues; foreach (DataRow row in dt.Rows) { dbValues = row["ListNumber"].ToString(); dbValues = dbValues.ToLower(); txtItems.Add(dbValues); } return txtItems.ToArray(); } protected void decoderViewSource() { SQL = "SELECT * FROM "; SQL = SQL + " tbl_X "; SQL = SQL + "WHERE "; SQL = SQL + " 1 "; if (ListNumber.Text != "") { SQL = SQL + " AND ListNumber ='" + ListNumber.Text + "' "; } Response.Write(SQL); try { OdbcDataAdapter adapter = new OdbcDataAdapter(SQL, myConnectionString); adapter.Fill(ds); DataView dv = new DataView(); dv = ds.Tables[0].DefaultView; DecoderView.DataSource = dv; DecoderView.DataBind(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { myConnectionString.Close(); } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { decoderViewSource(); } } <asp:TextBox ID="ListNumber" runat="server" AutoPostBack="true"></asp:TextBox> <asp:AutoCompleteExtender ID="AutoCompleteExtender1" TargetControlID="ListNumber" runat="server" ServiceMethod="GetCompletionList" UseContextKey="True" />



Reply With Quote

Bookmarks