本文介绍了ajax级联下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
am 使用 ajax级联下拉列表当页面加载时希望下拉列表应该选择到我在数据库中存储而不是选择国家/地区选项的国家/地区应 此 我的代码
public CascadingDropDownNameValue [] GetCountry( string knownCategoryValues, string category)
{
MNBusinessLogic.Admin adm = new MNBusinessLogic.Admin();
DataSet dsUpdate = adm.GetMasters( 0 , 国家/地区, 0 , true ,假跨度>);
List< CascadingDropDownNameValue> countrydetails = new 列表< CascadingDropDownNameValue>();
if (dsUpdate!= null && dsUpdate.Tables.Count > 0 && dsUpdate.Tables [ 0 ]。Rows.Count > 0 )
{
foreach (DataRow dtrow in dsUpdate.Tables [ 0 ] .Raw)
{
string CountryID = dtrow [ UID跨度>]的ToString();
string CountryName = dtrow [ MasterKey 跨度>]的ToString();
countrydetails.Add( new CascadingDropDownNameValue(CountryName,CountryID));
}
}
return countrydetails.ToArray();
}
和aspx代码
< asp:DropDownList ID = ddlC runat = server >
< / asp:DropDownList >
< ajaxToolkit:CascadingDropDown ID = cascadingddlC runat = server TargetControlID = ddlC PromptText = 选择国家/地区 LoadingText = 正在加载类别= 国家/地区 ServiceMethod = GetCountry ServicePath = cascadingHelper.asmx >
< / ajaxToolkit:CascadingDropDown >
解决方案
am using ajax cascading dropdownlist when the page gets load i want the dropdownlist should be selected to the country which i had store in database instead of select country option what i should do for it this is my code public CascadingDropDownNameValue[] GetCountry(string knownCategoryValues, string category) { MNBusinessLogic.Admin adm = new MNBusinessLogic.Admin(); DataSet dsUpdate = adm.GetMasters(0, "Country", 0, true, false); List<CascadingDropDownNameValue> countrydetails = new List<CascadingDropDownNameValue>(); if (dsUpdate != null && dsUpdate.Tables.Count > 0 && dsUpdate.Tables[0].Rows.Count > 0) { foreach (DataRow dtrow in dsUpdate.Tables[0].Rows) { string CountryID = dtrow["uid"].ToString(); string CountryName = dtrow["MasterKey"].ToString(); countrydetails.Add(new CascadingDropDownNameValue(CountryName, CountryID)); } } return countrydetails.ToArray(); } and aspx code is <asp:DropDownList ID="ddlC" runat="server"> </asp:DropDownList> <ajaxToolkit:CascadingDropDown ID="cascadingddlC" runat="server" TargetControlID="ddlC" PromptText="Select Country" LoadingText="Loading" Category="Country" ServiceMethod="GetCountry" ServicePath="cascadingHelper.asmx"> </ajaxToolkit:CascadingDropDown>
解决方案
这篇关于ajax级联下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!