How to save in the dropdown the value choosed?

后端 未结 1 927
不知归路
不知归路 2021-01-25 18:03
  • I have a simple gridview and a column with dropdownlist.
    • The dropdownlist is containing 2 values : Yes/No.
    • If I choose Yes //my code will execute but alw
1条回答
  •  梦毁少年i
    2021-01-25 18:36

    Try to set data source for dropdownlist only once on GET request. This issue happens cause you set data source everytime and you didn't persist selected item information.

     protected override OnLoad(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Ddl.DataSource = new DataSource();
                DdlIssues.DataBind();
            }
        }
    

    0 讨论(0)
提交回复
热议问题