I have the below code working greate except for one spot. After a user selects everything from the drop downs like they are suppose to, if they change the Semester in the first drop down, how can I make the dropdown for Houseing fresh as well?

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Tuition Calculator</title>
    <link type="text/css" rel="Stylesheet" href="style.css" />
</head>
<body>
    <div class="panelleft">
        <form id="form1" runat="server">
            <div id="FormTable">
                <div class="FTrow" id="Semester">
                    <div class="FTcell FTheader">Semester:</div>
                    <div class="FTcell">
                        <asp:DropDownList ID="SemesterDDL" runat="server" DataSourceID="SemesterDS" DataTextField="Semester_Name" DataValueField="Semester_ID" AppendDataBoundItems="true" AutoPostBack="true">
                            <asp:ListItem Value="" Text="" Selected="True"></asp:ListItem>
                        </asp:DropDownList>
                        <asp:HiddenField ID="SemesterID_HF" runat="server" />
                    </div>
                </div>
                <asp:Panel ID="Classification" runat="server" CssClass="FTrow" Visible="false">
                    <div class="FTcell FTheader">Classification:</div>
                    <div class="FTcell">
                        <asp:DropDownList ID="ClassificationDDL" runat="server" AppendDataBoundItems="true" AutoPostBack="true">
                            <asp:ListItem Selected="True"></asp:ListItem>
                            <asp:ListItem>Undergraduate</asp:ListItem>
                            <asp:ListItem>Graduate</asp:ListItem>
                        </asp:DropDownList>
                    </div>
                </asp:Panel>
                <asp:Panel CssClass="FTrow" id="Freshman" runat="server" Visible="false">
                    <div class="FTcell FTheader">Freshman:</div>
                    <div class="FTcell">
                        <asp:DropDownList ID="FreshmanDDL" runat="server" AppendDataBoundItems="true" AutoPostBack="true">
                            <asp:ListItem Selected="True"></asp:ListItem>
                            <asp:ListItem>Yes</asp:ListItem>
                            <asp:ListItem>No</asp:ListItem>
                        </asp:DropDownList>
                    </div>
                </asp:Panel>
                <asp:Panel CssClass="FTrow" id="Panel1" runat="server" Visible="false">
                    <div class="FTcell FTheader">Course:</div>
                    <div class="FTcell">
                        <asp:DropDownList ID="CourseDDL" runat="server" AppendDataBoundItems="true" AutoPostBack="true">
                            <asp:ListItem Selected="True"></asp:ListItem>
                            <asp:ListItem>Yes</asp:ListItem>
                            <asp:ListItem>No</asp:ListItem>
                        </asp:DropDownList>
                        <asp:HiddenField ID="CourseID_HF" runat="server" />
                    </div>
                </asp:Panel>
                <asp:Panel CssClass="FTrow" id="Residency" runat="server" Visible="false">
                    <div class="FTcell FTheader">Residency:</div>
                    <div class="FTcell">
                        <asp:DropDownList ID="ResidencyDDL" runat="server" AppendDataBoundItems="true" AutoPostBack="true">
                            <asp:ListItem Selected="True"></asp:ListItem>
                            <asp:ListItem>In State</asp:ListItem>
                            <asp:ListItem>Out of State</asp:ListItem>
                            <asp:ListItem>International</asp:ListItem>
                        </asp:DropDownList>
                    </div>
                </asp:Panel>
                <asp:Panel CssClass="FTrow" id="LearningStyle" runat="server" Visible="false">
                    <div class="FTcell FTheader">Learning Sytle:</div>
                    <div class="FTcell">
                        <asp:DropDownList ID="LearningDDL" runat="server" AppendDataBoundItems="true" AutoPostBack="true">
                            <asp:ListItem></asp:ListItem>
                            <asp:ListItem>In Person</asp:ListItem>
                            <asp:ListItem>Online</asp:ListItem>
                        </asp:DropDownList>
                    </div>
                </asp:Panel>
                <asp:Panel CssClass="FTrow" id="Housing" runat="server" Visible="false">
                    <div class="FTcell FTheader">Housing:</div>
                    <div class="FTcell">
                        <asp:DropDownList ID="HousingDDL" runat="server" AppendDataBoundItems="True" AutoPostBack="True" DataSourceID="HousingDS" DataTextField="Housing_Location" DataValueField="Housing_ID">
                            <asp:ListItem Value="" Text="" Selected="True"></asp:ListItem>
                        </asp:DropDownList>
                        <asp:HiddenField ID="HousingID_HF" runat="server" />
                    </div>
                </asp:Panel>
                <asp:Panel CssClass="FTrow" id="MealPlan" runat="server" Visible="false">
                    <div class="FTcell FTheader">Meal Plan:</div>
                    <div class="FTcell">
                        <asp:DropDownList ID="MealPlanDDL" runat="server" AppendDataBoundItems="True" AutoPostBack="True" DataSourceID="MealPlanDS" DataTextField="MealPlan_Name" DataValueField="MealPlan_ID">
                            <asp:ListItem Value="" Text="" Selected="True"></asp:ListItem>
                        </asp:DropDownList>
                        <asp:HiddenField ID="MealPlanID_HF" runat="server" />
                    </div>
                </asp:Panel>
                <div class="FTrow">
                    <div class="FTbuttons"><asp:Button ID="CalculateBtn" runat="server" Text="Calculate" Visible="false" /><asp:Button ID="ResetBtn" runat="server" Text="Reset" /></div>
                </div>
            </div>
            <asp:SqlDataSource ID="SemesterDS" runat="server" SelectCommand="SELECT [Semester_Name], [Semester_ID] FROM [tbl_Semester] WHERE ([Show_To_Public] = 1)" ConnectionString="<%$ ConnectionStrings:Tuition-CalculatorConnectionString %>">
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="HousingDS" runat="server" SelectCommand="SELECT [Housing_ID], [Housing_Location], [Housing_Type], [Semester_ID] FROM [tbl_Housing]" ConnectionString="<%$ ConnectionStrings:Tuition-CalculatorConnectionString %>" FilterExpression="Semester_ID='{0}'">
                <FilterParameters>
                    <asp:ControlParameter ControlID="SemesterDDL" PropertyName="SelectedValue" />
                </FilterParameters>
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="MealPlanDS" runat="server" SelectCommand="SELECT [MealPlan_Name], [MealPlan_ID] FROM [tbl_MealPlan]" ConnectionString="<%$ ConnectionStrings:Tuition-CalculatorConnectionString %>">
            </asp:SqlDataSource>
            <asp:Table ID="Table1" runat="server">
            </asp:Table>
        </form>
    </div>
    <div class="panelright">
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </div>
</body>
</html>

Set the autoPostBack for the semester drop down to true (I think it is already) and add the onSelectedIndexChanged event to your code behind. Now when the value in the semester drop down is changed that method will fire and you can make whatever changes you need to the housing drop down.

<asp:DropDownList ID="SemesterDDL" runat="server" DataSourceID="SemesterDS" DataTextField="Semester_Name" DataValueField="Semester_ID" AppendDataBoundItems="true" AutoPostBack="true" onSelectedIndexChanged="SemesterDDL_OnSelectedIndexChanged">

Then in your code behind define the SemesterDDL_OnSelectedIndexChanged method.

Hi Bro. You can use Update panel of Ajax Control. It is lite and easy to use.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.