简体   繁体   中英

GridView1: How to save the selected value from the dropdownlist and make it visible

  • I have a dropdownlist.
    • A column called id has the control dropdownlist ( I've changed the textbox into a dropdownlist).
    • The dropdownlist is containing 2 values : Yes/No .

On gridview row update I want to save the value choosed in the dropdownlist . how can I do that? Also,how can I make the value choosed in the dropdown visible in the gridview.

thans

Try something like this

   protected void GridViewRowUpdating(object sender, GridViewUpdateEventArgs e)
    {
          var rowIndex = e.RowIndex;
          var row = GridView.Rows[rowIndex];
          var ddl = row.FindControl("YOURDROPDOWN") as DropDownList;
          if(ddl != null)
          var value = ddl.SelectedValue;
    }

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