孟买3 两个下拉列表名称是ddldistrict,ddltaluk(这里ddldistrict是父级,ddltaluk是小孩) 文本框名称是txtdistrictcode 如果我选择ddldistrict像bangalore,chennai,mumbai有关districtid将绑定在txtdistrictcode文本框中并且有关taluk将填写ddltaluk让我们说如果我在ddldistrict中选择bangalore为该bangalore id为1所以1 ll bind in the districtid工作正常的文本框。现在的问题是如果我在ddldistrictid中键入1,相关的bangalore应该绑定在ddldistrict中也工作正常但子文本框(ddltaluk)没有填充并且它被禁用。但是,如果我选择了ddldistrict bangalore,districtid就会绑定,而taluk也会填充。 我使用jquery进行双向绑定(ddldistrict到txtdistrictid和txtdistrictid到ddldistrict) $( #ContentPlaceHolder1_ddlDistrict)。live ( change, function () { var selectedText = $( # ContentPlaceHolder1_ddlDistrict选项:选中)。val(); if (selectedText!= ){ $(' #ContentPlaceHolder1_txtDistrict_Code_I')。val(selectedText); } else if (selectedText == ){ $(' .ajax__validatorcallout_popup_table_row' )隐藏(); $(' #ContentPlaceHolder1_ddlDistrict')。focus(); $(' #ContentPlaceHolder1_txtDistrict_Code_I')。val(' '); } 其他 { $(' #ContentPlaceHolder1_txtDistrict_Code_I')。val(' '); $(' #ContentPlaceHolder1_ddlDistrict')。val(' '); alert(' 所选区域没有代码'); $(' #ContentPlaceHolder1_ddlDistrict')。focus(); } }); $( #ContentPlaceHolder1_txtDistrict_Code_I)。live( focusout, function (){ var selectedText = $( #ContentPlaceHolder1_txtDistrict_Code_I)。val(); if (selectedText!= ){ $(' #ContentPlaceHolder1_ddlDistrict' ).val(selectedText); var selectedvalue = $( #ContentPlaceHolder1_ddlDistrict选项:选中)。val(); if (sel ectedvalue == ){ alert( 无效的区号,请输入有效的代码); $( #ContentPlaceHolder1_txtDistrict_Code_I)。val(' '); $( #ContentPlaceHolder1_txtDistrict_Code_I)。focus(); } } }); 对于填充级联下拉列表,我使用了webservices: 父控制 [WebMethod] public Ajx [] get_Districts(字符串 knownCategoryValues,字符串类别) { DataTable dtMainModule = new DataTable(); string StateID; StringDictionary MainModuleValues = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); StateID = 09; // MainModuleValues [StateID]; dtMainModule = odal.ReturnDt( @ 从bindDimpa.tblDistrict中选择不同的fldDistrictCode,fldDistrictName,其中fldStateID =' + StateID + '按fldDistrictName排序); 列表< AJX> objMainModule = new 列表< AJX>(); foreach (DataRow dr in dtMainModule.Rows) { objMainModule.Add( new Ajx(Convert.ToString(dr [ fldDistrictName]),Convert.ToString(dr [ fldDistrictCode]))); } return objMainModule.ToArray(); } 子控件 [WebMethod] public CascadingDropDownNameValue [] getTaluks( string knownCategoryValues, string category) { DataTable dtMainModule = new DataTable(); string fldDistrictID; StringDictionary MainModuleValues = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); fldDistrictID = MainModuleValues [ DistrictID]; dtMainModule = odal.ReturnDt( @ 从bindPS.tblVillage中选择DISTINCT Dist_TehsilID,Tehsilaspercensus2001,其中TehsilID不为null和DistrictID =' + fldDistrictID + '); List< cascadingdropdownnamevalue> objMainModule = new List< cascadingdropdownnamevalue>(); foreach (DataRow dr in dtMainModule.Rows) { objMainModule.Add( new CascadingDropDownNameValue(Convert.ToString(dr [ Tehsilaspercensus2001]),Convert.ToString(dr [ Dist_TehsilID]))); } return objMainModule.ToArray(); } < / cascadingdropdownnamevalue > < / cascadingdropdownnamevalue > 解决方案 ( #ContentPlaceHolder1_ddlDistrict)。live( change, function (){ var selectedText = ( #ContentPlaceHolder1_ddlDistrict选项:选择)。val(); if (selectedText!= ){ (' #ContentPlaceHolder1_txtDistrict_Code_I')。val(selectedText); } else if (selectedText == ){ I have 2 dropdownlist and 1 textbox i m filling dropdown using webservice..District DistrictCodebangalore 1chennai 2mumbai 3Two dropdownlist names are ddldistrict,ddltaluk( here ddldistrict is parent, ddltaluk is child)textbox name is txtdistrictcodeif i selected ddldistrict like bangalore,chennai,mumbai that concerned districtid will bind in the txtdistrictcode textbox and concerned taluk will fill in the ddltaluk Let's say if i selected bangalore in ddldistrict for that bangalore id is 1 so 1 ll bind in the districtid textbox that is working fine.Now the problem is if i type 1 in ddldistrictid the concerned bangalore should bind in the ddldistrict that also working fine but the child textbox(ddltaluk) is not filling and it is disabled. But if i selected ddldistrict bangalore the districtid is binding and taluk is also filling.I used jquery for bidirection binding( ddldistrict to txtdistrictid and txtdistrictid to ddldistrict)$("#ContentPlaceHolder1_ddlDistrict").live("change", function () { var selectedText = $("#ContentPlaceHolder1_ddlDistrict option:selected").val(); if (selectedText != "") { $('#ContentPlaceHolder1_txtDistrict_Code_I').val(selectedText); } else if (selectedText == "") { $('.ajax__validatorcallout_popup_table_row').hide(); $('#ContentPlaceHolder1_ddlDistrict').focus(); $('#ContentPlaceHolder1_txtDistrict_Code_I').val(''); } else { $('#ContentPlaceHolder1_txtDistrict_Code_I').val(''); $('#ContentPlaceHolder1_ddlDistrict').val(''); alert('There is no Code for Selected District'); $('#ContentPlaceHolder1_ddlDistrict').focus(); } }); $("#ContentPlaceHolder1_txtDistrict_Code_I").live("focusout", function () { var selectedText = $("#ContentPlaceHolder1_txtDistrict_Code_I").val(); if (selectedText != "") { $('#ContentPlaceHolder1_ddlDistrict').val(selectedText); var selectedvalue = $("#ContentPlaceHolder1_ddlDistrict option:selected").val(); if (selectedvalue == "") { alert("Invalid District Code, Please Enter valid Code"); $("#ContentPlaceHolder1_txtDistrict_Code_I").val(''); $("#ContentPlaceHolder1_txtDistrict_Code_I").focus(); } } });For Filling Cascading dropdownlist i used webservices:Parent Control[WebMethod] public Ajx[] get_Districts(string knownCategoryValues, string category) { DataTable dtMainModule = new DataTable(); string StateID; StringDictionary MainModuleValues = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); StateID = "09";// MainModuleValues["StateID"]; dtMainModule = odal.ReturnDt(@"select distinct fldDistrictCode,fldDistrictName from bindDimpa.tblDistrict where fldStateID='" + StateID + "' order by fldDistrictName"); List< Ajx> objMainModule = new List< Ajx>(); foreach (DataRow dr in dtMainModule.Rows) { objMainModule.Add(new Ajx(Convert.ToString(dr["fldDistrictName"]), Convert.ToString(dr["fldDistrictCode"]))); } return objMainModule.ToArray(); }Child Control[WebMethod] public CascadingDropDownNameValue[] getTaluks(string knownCategoryValues, string category) { DataTable dtMainModule = new DataTable(); string fldDistrictID; StringDictionary MainModuleValues = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); fldDistrictID = MainModuleValues["DistrictID"]; dtMainModule = odal.ReturnDt(@"select DISTINCT Dist_TehsilID,Tehsilaspercensus2001 from bindPS.tblVillage where TehsilID is not null and DistrictID='" + fldDistrictID + "'"); List<cascadingdropdownnamevalue> objMainModule = new List<cascadingdropdownnamevalue>(); foreach (DataRow dr in dtMainModule.Rows) { objMainModule.Add(new CascadingDropDownNameValue(Convert.ToString(dr["Tehsilaspercensus2001"]), Convert.ToString(dr["Dist_TehsilID"]))); } return objMainModule.ToArray(); }</cascadingdropdownnamevalue></cascadingdropdownnamevalue> 解决方案 ("#ContentPlaceHolder1_ddlDistrict").live("change", function () { var selectedText =("#ContentPlaceHolder1_ddlDistrict option:selected").val(); if (selectedText != "") {('#ContentPlaceHolder1_txtDistrict_Code_I').val(selectedText); } else if (selectedText == "") { 这篇关于如何使用jquery启用下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-12 21:47