title: How to get values from multiple DropDownLists in a GridView on button_click?
body: <p>I have a <code>GridView</code> on my asp.net webform with all the columns and rows created in C# code from behind. Except the first column, every cell in each column is a <code>DropDownList</code> with a <code>DataSource</code>.</p>
  
  <p>Here is my <code>GridView</code>:</p>
  
  <pre><code> &lt;asp:GridView ID="gv_Rota" runat="server" AutoGenerateColumns="false" OnRowDataBound="gv_Rota_RowDataBound"&gt;
                       &lt;HeaderStyle BackColor="#6a3d98" ForeColor="White" Height="20" /&gt;
                       &lt;RowStyle HorizontalAlign="Center" Height="20px" Width="100px" /&gt;
                       &lt;AlternatingRowStyle Height="20px" /&gt;
                   &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>And the c# creation of the columns and cells:</p>
  
  <pre><code> private void BindGrid(int Amount)
      {
          gv_Rota.DataSource = null;
          gv_Rota.Columns.Clear();
  
          BoundField bfield = new BoundField();
          bfield.HeaderText = "Days";
          bfield.DataField = "Days";
          gv_Rota.Columns.Add(bfield);
  
          for (int i = 0; i &lt; Amount; i++)
          {
              int week = i + 1;
              string sWeek = "Week " + week.ToString();
  
              TemplateField tfield = new TemplateField();
              tfield.HeaderText = sWeek;
              gv_Rota.Columns.Add(tfield);
          }
  
          DataTable dt = new DataTable();
          dt.Columns.Add(new DataColumn("Days", typeof(string)));
          dt.Rows.Add("M");
          dt.Rows.Add("T");
          dt.Rows.Add("W");
          dt.Rows.Add("T");
          dt.Rows.Add("F");
          dt.Rows.Add("S");
          dt.Rows.Add("S");
          gv_Rota.DataSource = dt;
          gv_Rota.DataBind();
      }
  </code></pre>
  
  <p>And then on the <code>RowDataBound</code> trigger of my <code>GridView</code>, I add the <code>DropDownList</code> control to every cell:</p>
  
  <pre><code>protected void gv_Rota_RowDataBound(object sender, GridViewRowEventArgs e)
      {
          for (int i = 1; i &lt;= ColumnCount; i++)
          {
              if (e.Row.RowType == DataControlRowType.DataRow)
              {
                  ddlShift = new DropDownList();
                  ddlShift.ID = "ddlShift";
                  ddlShift.DataSource = DCListOfShifts;
                  ddlShift.DataValueField = "SHIFT_ID";
                  ddlShift.DataTextField = "SHIFT_NAME";
                  ddlShift.DataBind();
                  ddlShift.Items.Insert(0, new ListItem("Shift..."));
                  ddlShift.CssClass = "ddl_rotamanager";
                  e.Row.Cells[i].Controls.Add(ddlShift);
              }
          }  
      }
  </code></pre>
  
  <p>What is displayed for example on my page:</p>
  
  <p><img src="https://i.stack.imgur.com/ES6KO.jpg" alt="enter image description here"></p>
  
  <p>So my question and problem is that I now want to save each column (except the first) to a database, as a "scheduled week", and have no idea how to get the values of selected items in all or any of the <code>DropDownLists</code> to then pass that back to the database. <strong>Baring in mind, this is NOT done on <code>selectedindexchanged</code>. I will select items from all the <code>DropDownLists</code> and then press a button to submit the values.</strong> Please could someone give me some highlight on how this could be done? Thanks.</p>
  
  <p><strong>EDIT 1:</strong> Response explains how I could get every value of a DropDownList in a row or by individual cell. However, now I need to know more specifically how I can get values of specific cells in the <strong>columns</strong> rather than the rows. Is it possible to get further highlight on this? </p>