简体   繁体   English

下拉列表选定值

[英]Drop down list Selected value

I implemented a drop down in my ASP.net page .I put data sourse and bind drop down in page load event . 我在ASP.net页面中实现了下拉菜单。我在页面加载事件中放置了数据源和绑定下拉菜单。 I get the data in the drop down without any problem . 我在下拉列表中得到的数据没有任何问题。 But when i selected a value it always send index 1 value . 但是,当我选择一个值时,它总是发送索引1值。 I tried different values but it always sends the index 1 value to the backend 我尝试了不同的值,但是它总是将索引1的值发送到后端

string[] parity = conData.GetParity();
                ddlParity.DataSource = parity.ToList();
                ddlParity.DataBind();



modemDetailsObj.Parity = ddlParity.SelectedValue;

You are probably binding the dropdown in postback again. 您可能会再次绑定回发中的下拉列表。 You need to bind it in !Postback 您需要将其绑定到!

if(!Page.IsPostBack)
{
   string[] parity = conData.GetParity();
            ddlParity.DataSource = parity.ToList();
            ddlParity.DataBind();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM