自动扩展器不工作 [英] Auto extender Not Working

查看:60
本文介绍了自动扩展器不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:TextBox ID="txt_vech_no" runat="server"></asp:TextBox>

                                                        <cc1:AutoCompleteExtender ID="AutoCompleteExtender4" runat="server" TargetControlID="txt_vech_no" MinimumPrefixLength="1"

                                                             EnableCaching="true" CompletionSetCount="1" CompletionInterval="0" ServiceMethod="get_vehicleno"></cc1:AutoCompleteExtender>













[System.Web.Script.Services.ScriptMethod()]
       [System.Web.Services.WebMethod]
       public static List<string> get_vehicleno(string prefixText)
       {
           SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["BMS"].ToString());
           con.Open();
           SqlCommand cmd15 = new SqlCommand("select * from tbl_vehicle where vehicle_registration_no like @Name+'%'", con);
           cmd15.Parameters.AddWithValue("@Name", prefixText);
           SqlDataAdapter da15 = new SqlDataAdapter(cmd15);
           DataTable dt15 = new DataTable();
           da15.Fill(dt15);
           List<string> CountryNames12 = new List<string>();
           for (int i = 0; i < dt15.Rows.Count; i++)

           {

               CountryNames12.Add(dt15.Rows[i][1].ToString());

           }

           return CountryNames12;

       }









您好,我通过我的项目使用上面的autoextender代码,但它不适用于这个特定的textbox.please帮助我。





Hi im using the above code for autoextender through out my project but its not working for this perticular textbox.please help me out.

推荐答案

hi

您的TargetControlID是txt_vech_no,但是你传递了来自prefixText Textbox.So的值。对于我的建议你只需传递txt_vech_no代替prefixText并写下编码行为



cmd15.Parameters.AddWithValue(@ Name,txt_vech_no.Text.Trim());
hi
your TargetControlID is txt_vech_no but you passed the value from prefixText Textbox.So for my suggestion you just pass txt_vech_no in place of prefixText and write the line of coding as

cmd15.Parameters.AddWithValue("@Name", txt_vech_no.Text.Trim() );


这篇关于自动扩展器不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆