本文介绍了在文本框textchange上的下拉列表中自动填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好, 我在DropDown列表中自动填充一些数据,取决于文本框中的值。 我将textbox的AutoPostBack属性设置为true。并且这两个控件都在updatePanel中。 但是使用VPN网络在下拉列表中自动填充需要花费很多时间。因为我已经在sql的表中应用了 索引,我正在从中选择数据。 Plz帮助我解决问题。 这是我的文本框代码: Hi All, I'm autopopulating some data in DropDown List, depends upon value in textbox.I've set AutoPostBack property of textbox to true. And both the controls are in updatePanel.But using VPN network It is taking so much time to auto populate in dropdown list. As I've applied indexing also on table in sql from which i'm selecting data.Plz help me what is the issue.This is my code for textbox :<asp:TextBox ID="txtPinCode" runat="server" CssClass="txtbox" TabIndex="23" onblur="CheckPincode(this);" AutoPostBack="True" ontextchanged="txtPinCode_TextChanged" ToolTip="Pincode must be 4 to 9 Integers" MaxLength="6"></asp:TextBox> 这是在下拉菜单中自动填充的代码: And this is code to autopopulate in dropdown :protected void txtPinCode_TextChanged(object sender, EventArgs e) { try { string pincode = txtPinCode.Text; double pin; bool isNum = double.TryParse(pincode, out pin); if (isNum) { txtPinCode.CssClass = "txtbox"; pd.PinCode = txtPinCode.Text; pd.ID = 1; DataTable dt = new DataTable(); dt = hd.GetPODetails(pd); if (dt.Rows.Count > 0) { lblErrPinCode.Visible = false; ddlPostOffice.DataTextField = dt.Columns["Description"].ToString(); ddlPostOffice.DataValueField = dt.Columns["ID"].ToString(); ddlPostOffice.DataSource = dt; ddlPostOffice.DataBind(); ddlPostOffice.Items.Insert(0, new ListItem("---Select---", "0")); pd.PinCode = txtPinCode.Text; pd.ID = 3; DataTable dtDist = new DataTable(); dtDist = hd.GetPODetails(pd); if (dtDist.Rows.Count > 0) { txtDistrict.Text = dtDist.Rows[0]["DISTRICT_NAME"].ToString(); } } else { ddlPostOffice.Items.Clear(); lblErrPinCode.Visible = true; lblErrPinCode.Text = "Pincode and Post Office details does not exist."; } } else { txtPinCode.CssClass = "errtxtWidth200"; } } catch (SqlException Sqlex) { if (Sqlex.Number == -2) { string error = Sqlex.Message; ErrorLogs(error); Alert.Show("Timeout occured. Please try later"); } } catch (Exception ex) { string error = ex.Message; ErrorLogs(error); } } 推荐答案 <head runat="server"> <title></title> <script src="jquery-1.8.3.min.js" type="text/javascript"></script> <script src="jquery.tmpl.js" type="text/javascript"></script> <script type="text/javascript"> function getsuggestions(event) { 这篇关于在文本框textchange上的下拉列表中自动填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-25 02:53