Ajay Rawat Ajay Rawat - 2 months ago 37
ASP.NET (C#) Question

get the value of dropdown on asp button click

I'm trying to populate on dropdown(i.e dropdown2) on the value basis of other dropdown(i.e dropdown1), It's populate fine,now my problem is when i'm click on asp button to get the selected value of dropdown 2 it will be return blank value, I'm not not understand what is going wrong?


<select runat="server" id="ddlFilter" ClientIDMode="Static">
<option value="0">Both</option>
<option value="1">Add new</option>
<select runat="server" id="ddlDepartment" ClientIDMode="Static"></select>
<asp:Button ID="btnSearch" runat="server" Text="Show Report" CssClass="search_btn" onclick="btnSearch_Click" />


$(document).ready(function () {
$("#ddlFilter").change(function () {
if ($("#ddlFilter").val() > 0) {
$("#ddlDepartment").append( < option > New < option > );


protected void btnSearch_Click(object sender, EventArgs e) {
string val= ddlDepartment.Value;


You can't get selected value from dropdown if you adding options in javascript. you can use:

string selectedValue = Request.Form[ddlDepartment.UniqueID];

See Question