简体   繁体   中英

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 . I get the data in the drop down without any problem . But when i selected a value it always send index 1 value . I tried different values but it always sends the index 1 value to the backend

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();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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