0

In one of my form there were two Dropdown fields. The second dropdown has to be populated from the database, dynamically from the selection of first dropdown.

Any help is appreciated.

2
  • Hi karthik, posting the screenshot of the UI gives no insight to what you trying to achieve or what you have already tried... Try explaining more. Commented Oct 7, 2012 at 7:27
  • hi @loxxy i do not how to begin as i have told im beginner trying to learn it googled it for so much time did not able to find, so i felt would get some help here Commented Oct 7, 2012 at 7:30

1 Answer 1

3

In the SelectedIndexChanged event of the first DropDownList, add code to populate the second DropDownList based on the selected value of the first list

Like this:

<asp:DropDownList runat="server" ID="from" AutoPostBack="true" CausesValidation="false" OnSelectedIndexChanged="from_SelectedIndexChanged">
</asp:DropDownList>

<asp:DropDownList runat="server" ID="to" />

    protected void from_SelectedIndexChanged(object sender, EventArgs e)
    {
        var selectedValue = this.from.SelectedValue;

        this.to.DataSource = /*get the data of the second list based on: selectedValue*/;
        this.to.DataBind();
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.