Passing first values in drop down list when clicking search button

cdhhgdledif

New Member
I have an asp Button and four drop down lists that are populated dynamically from a database. When clicking the button, supposed to pass the selected values from the drop down list to a SQL stored procedure. Instead the first value in each drop down list is being passed instead of the selected value. Here is the code on the aspx page:\[code\]<asp:DropDownList runat="server" ID="ddlCountry" AppendDataBoundItems="True"></asp:DropDownList>&nbsp;<asp:DropDownList runat="server" ID="ddlTypeStructure" AppendDataBoundItems="True"> </asp:DropDownList>&nbsp;<asp:DropDownList runat="server" ID="ddlCategory" AppendDataBoundItems="True"></asp:DropDownList>&nbsp;<asp:DropDownList runat="server" ID="ddlSegment" AppendDataBoundItems="True"></asp:DropDownList>&nbsp;<asp:Button runat="server" ID="btnSearhProjects" Text="Go" CausesValidation="False" onclick="btnSearhProjects_Click" UseSubmitBehavior="False" />\[/code\]And here is the C# code behind for the button:\[code\]protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindCountries(); BindCategories(); BindSegments(); BindStructures(); //BindProjects(); } }public void SearchProjects() { Project project = new Project(); string country = ddlCountry.SelectedItem.Text; string category = ddlCategory.SelectedItem.Text; string segment = ddlSegment.SelectedItem.Text; string structure = ddlTypeStructure.SelectedItem.Text; List<Project> projectList = project.GetProjects(country, category, segment, structure); gvProjects.DataSource = projectList; gvProjects.DataBind(); } protected void btnSearhProjects_Click(object sender, EventArgs e) { SearchProjects(); }\[/code\]I have tried using \[code\]ddlCountry.SelectedValue.Text\[/code\] and \[code\]ddlCountry.SelectedItem.Value\[/code\] and they do not work. Any help would be greatly appreciated. Thank you.
 
Back
Top