首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

AutoComplete模糊查询匹配关联控件的有关问题

2013-10-17 
AutoComplete模糊查询匹配关联控件的问题一个页面上有两个TextBox框,分别是任务编号TextBox和任务名称Text

AutoComplete模糊查询匹配关联控件的问题

一个页面上有两个TextBox框,分别是任务编号TextBox和任务名称TextBox
数据库表tableC
Id  OrderNo(任务编号)   OrderName(任务名称)
1   201310120001       任务名称1
2   201310120002       任务名称2

前台页面:


<asp:ScriptManager ID="ScriptManager1" runat="server">
                                                                                        </asp:ScriptManager>
                                                                                        <div>
        //任务编号TextBox                                                                                    <asp:TextBox ID="txt_OrderNo" runat="server" autocomplete="off" Width="300"></asp:TextBox>
                                                                                            <cc1:AutoCompleteExtender ID="autoComplete1" runat="server" CompletionInterval="1000"
                                                                                                CompletionSetCount="12" EnableCaching="true" MinimumPrefixLength="0" ServiceMethod="GetList"
                                                                                                ServicePath="WebService1.asmx" TargetControlID="txt_OrderNo">
                                                                                            </cc1:AutoCompleteExtender>

                                                                                            <script type="text/javascript">
                var frm = document.getElementById("aspnetForm");
                if (frm) {
                    frm.onsubmit = function() { return false; };
                }
                                                                                            </script>                                                                       </div>



//任务名称TextBox
<asp:TextBox id="txt_OrderName" runat="server" ></asp:TextBox>




WebService1里面的方法:


public string[] GetList(string prefixText, int count)
        {
            if (count == 0)
            {
                count = 10;
            }

            Random random = new Random();
            List<string> items = new List<string>(count);

            string str7="";
            string str2="";
            string strSql = "select * from tableC ";
            DataTable mytable = rdtable(strSql);
            if (mytable.Rows.Count > 0)
            {
                for (int a = 0; a < mytable.Rows.Count; a++)
                {
                    if (a != mytable.Rows.Count-1)
                    {
                        str7 += mytable.Rows[a]["OrderNo"].ToString() + ",";
                        str2 += mytable.Rows[a]["OrderName"].ToString() + ",";

                    }
                    else if (a == mytable.Rows.Count - 1)
                    {
                        str7 += mytable.Rows[a]["OrderNo"].ToString();
                        str7 += mytable.Rows[a]["OrderName"].ToString();

                    }

                }
                
            }          

            string[] strOrderNo = str7.Split(',');  
            string[] strOrderName = str2.Split(',');      
            
            for (int i = 0; i < strOrderNo.Length; i++)
            {
                if (strOrderNo[i].IndexOf(prefixText) >= 0)            
                {
                    items.Add(strOrderNo[i]);
                }     
            }

            return items.ToArray();
        }






在任务编号TextBox中选择了一个任务编号之后,我希望在任务名称TextBox中也要显示相应的内容,请问这个代码应该如何继续写下去?




[解决办法]
http://download.csdn.net/detail/lifetimeus/3349813

热点排行