如果使用AJAX更改了其他下拉索引,则填充下拉列表 [英] Fill Dropdown if other dropdown index changed using AJAX
问题描述
申请您可以让我获得宝贵的解决方案:
我有一个项目,我必须在其中填充DropDownList(数据库中的DDProjectIDList),如果用户选择projectID,则必须填写相应的客户列表(DropDownList).这些所有数据都在sql数据库中.
我必须用AJAX来做.
感谢您的帮助
Shaan
Appriciate u can let me the precious solution :
I have a project in which i have to fill the DropDownList(DDProjectIDList from database), and if user select the projectID, then corresponding customer list(DropDownList) must be filled . These all data is there in the sql database.
I have to do it by AJAX.
Thanx for your help
Shaan
推荐答案
使用Google或使用代码项目搜索...
使用:级联下拉列表 + ASP.NET作为关键字...
您将获得大量的材料,代码和控制权!
Use Google or Use Code Project Search...
Use:Cascading Dropdown + ASP.NET as keywords...
you would get lots of material, code, control on it!
Shaan,
请按照步骤
1.将两个下拉菜单都放在UpdatePanel中.
2.为第一个下拉菜单添加onchange事件.
3.在事件处理程序中,填写第二个下拉列表(仅在服务器端以及其他任何下拉列表中).
Shaan,
Follow the steps
1. Place both the dropdowns in a UpdatePanel.
2. Add onchange event for the first dropdown.
3. In the event handler fill the second dropdown (on serverside only as do for any other).
Shaan
在这里,我根据国家更改了州..
在javascript中根据您的要求添加此..
Shaan
here i changed the state based on the country ..
in javascript add this.. based on ur requirement..
<code><pre lang="xml"><asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlcountry" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlcountry_SelectedIndexChanged" >
</asp:DropDownList>
<br />
<br />
<br />
<asp:DropDownList ID="ddlstate" runat="server"
AutoPostBack="True" ></asp:DropDownList>
并在第一个代码库中添加绑定数据,例如在ddlcountry_SelectedIndexChanged事件中(我使用过LINQ)
and in codebahind jst add bind the data for example in ddlcountry_SelectedIndexChanged event(i have used LINQ)
IEnumerable<State> res = db.States.Where(s => s.CountryId ==int .Parse (ddlcountry.SelectedValue));<br />
ddlstate.DataSource = sl;<br />
ddlstate.DataTextField = "StateName";<br />
ddlstate.DataValueField = "StateId";<br />
<br />
ddlstate.DataBind();<br />
<br />
这篇关于如果使用AJAX更改了其他下拉索引,则填充下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!