Hi guys,
I Have 2 DropDownList: DropDownList_1 and DropDownList_2where DropDownList_2 content will be dependent to DropDownList_1 selected
value. I'm new in using UpdatePanel. here is my code:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate> <asp:DropDownList ID="DropDownList_1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList_1_SelectedIndexChanged"
DataSourceID="department" DataTextField="DepartmentNAme" DataValueField="Id"></asp:DropDownList> </ContentTemplate>
<Triggers> <asp:AsyncPostBackTrigger ControlID="DropDownList_1" EventName="SelectedIndexChanged" /> </Triggers>
</asp:UpdatePanel> <asp:DropDownList ID="DropDownList_2" runat="server" DataSourceID="subject"
DataTextField="StudentName" DataValueField="StudentID"></asp:DropDownList>
CS code:
protected void DropDownList_1_SelectedIndexChanged(object sender, EventArgs e)
{ SqlDataSource1.SelectCommand = "SELECT DISTINCT * FROM [Student] WHERE StudentID="+DropDownList_1.SelectedValue; DropDownList_2.DataBind(); }
its working fine as stated above, only the problem is that the whole page refreshes, I also tried removing AutoPostBack="true" in my DropDownList_1 but it stops working, how to fix this? Thanks!