Reputation: 1
I have two dropdownlists ID and Name
If I select ID then Names under that ID should be displayed.
I tried it with using autopostback event,But i want to use it through AJAX or JAVAscript as per my requirement.
how to use pastbackevent with ajax or javascript
If i select ID 2 then Names Dropdown should be changed.I tried using script on selectchangeindex event but it not works
Upvotes: 0
Views: 186
Reputation: 6105
In easy way , I suggest you to use UpdatePanel
. For Example ,
In aspx ,
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList runat="server" ID="dropDownOne">
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="dropDownTwo" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<asp:DropDownList runat="server" ID="dropDownTwo" AutoPostBack="true"
OnSelectedIndexChanged="Two_SelectedIndexChanged" ></asp:DropDownList>
In cs ,
protected void Two_SelectedIndexChanged(object sender, SelectedIndexChangedEventArgs e)
{
//......Rebind dropDownOne's datasource here !.....
}
In my example , dropDownTwo
will be your ID_dropdownList
and dropDownOne
will be your Name_DropDownList
. Good Luck !
Upvotes: 2