Read Data From Gridview DropDownList
<p>This exact code works on another page but not the one I am working on. I have copy and pasted it from my other page but cannot figure out whats going wrong. Hoping it is something easy.</p>

<p>I have a gridview that has a few dropdownlists and textboxes. when I click the btnApproveSave button it is supposed to read the data in the gridview and then perform an update on the database. However the c# isn't reading anything for the dropdownlists or textboxes in each row of the gridview.</p>

<pre><code>&lt;asp:Button ID="btnApprove" runat="server" OnClick="btnApprove_Click" Text="Submit Approval" /&gt;
            &amp;nbsp;&amp;nbsp;&amp;nbsp;
            &lt;asp:Button ID="btnApproveSave" runat="server" Text="Save Entries" OnClick="btnApproveSave_Click" /&gt;
            &lt;br /&gt;
            &lt;asp:Label ID="lblError" runat="server" Text="Please Verify That All Fields Have Been Filled Out" Visible="false" ForeColor="#D71826" /&gt;
            &lt;br /&gt;
            &lt;br /&gt;
            &lt;div class="form-group"&gt;
                &lt;asp:GridView ID="gvCreditCards" runat="server" Visible="true" ShowHeaderWhenEmpty="true" AutoGenerateColumns="false"&gt;
                    &lt;Columns&gt;
                        &lt;asp:BoundField DataField="id" HeaderText="ID" ItemStyle-CssClass="gvCCPadding" /&gt;
                        &lt;asp:BoundField DataField="fin_transaction_date" HeaderText="Transaction Date" ItemStyle-CssClass="gvCCPadding" ItemStyle-Width="50%" DataFormatString="{0:MM/dd/yyyy}" /&gt;
                        &lt;asp:BoundField DataField="acc_account_name" HeaderText="Account Name" ItemStyle-CssClass="gvCCPadding minWidth" /&gt;
                        &lt;asp:BoundField DataField="fin_charge" HeaderText="Charge" ItemStyle-CssClass="gvCCPadding" DataFormatString="{0:C}" ItemStyle-HorizontalAlign="Right" /&gt;
                        &lt;asp:BoundField DataField="fin_transaction_description" HeaderText="Vendor Name" ItemStyle-CssClass="gvCCPadding minWidth" /&gt;
                        &lt;asp:BoundField DataField="mch_state_province" HeaderText="State" ItemStyle-CssClass="gvCCPadding" /&gt;
                        &lt;asp:TemplateField HeaderText="Description" ControlStyle-Width="150px"&gt;
                            &lt;ItemTemplate&gt;
                                &lt;asp:TextBox ID="txtUserDescription" runat="server" Text='&lt;%# Eval("toa_user_description") %&gt;' /&gt;
                            &lt;/ItemTemplate&gt;
                        &lt;/asp:TemplateField&gt;
                        &lt;asp:TemplateField HeaderText="Receipt (Y/N)" ControlStyle-Width="75px"&gt;
                            &lt;ItemTemplate&gt;
                                &lt;asp:DropDownList ID="ddlReceipt" runat="server"&gt;
                                    &lt;asp:ListItem Text="" Selected="True" Value=""&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Text="Yes" Selected="False" Value="Yes"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Text="No" Selected="False" Value="No"&gt;&lt;/asp:ListItem&gt;
                                &lt;/asp:DropDownList&gt;
                            &lt;/ItemTemplate&gt;
                        &lt;/asp:TemplateField&gt;
                        &lt;asp:TemplateField HeaderText="GL Code" ControlStyle-Width="200px"&gt;
                            &lt;ItemTemplate&gt;
                                &lt;asp:DropDownList ID="ddlGLCode" runat="server" DataSourceID="ds_AccountCode" DataValueField="toa_account_name" AppendDataBoundItems="true"&gt;
                                    &lt;asp:ListItem Selected="True" Text="" Value=""&gt;&lt;/asp:ListItem&gt;
                                &lt;/asp:DropDownList&gt;
                            &lt;/ItemTemplate&gt;
                        &lt;/asp:TemplateField&gt;
                        &lt;asp:TemplateField HeaderText="Department" ControlStyle-Width="200px"&gt;
                            &lt;ItemTemplate&gt;
                                &lt;asp:DropDownList ID="ddlDepartment" runat="server" DataSourceID="ds_Department" DataValueField="toa_businessDepartment" AppendDataBoundItems="true"&gt;
                                    &lt;asp:ListItem Selected="True" Text="" Value=""&gt;&lt;/asp:ListItem&gt;
                                &lt;/asp:DropDownList&gt;
                            &lt;/ItemTemplate&gt;
                        &lt;/asp:TemplateField&gt;
                        &lt;asp:TemplateField HeaderText="Location" ControlStyle-Width="200px"&gt;
                            &lt;ItemTemplate&gt;
                                &lt;asp:DropDownList ID="ddlLocation" runat="server" DataSourceID="ds_businessLocation" DataValueField="toa_site" AppendDataBoundItems="true"&gt;
                                    &lt;asp:ListItem Selected="True" Text="" Value=""&gt;&lt;/asp:ListItem&gt;
                                &lt;/asp:DropDownList&gt;
                            &lt;/ItemTemplate&gt;
                        &lt;/asp:TemplateField&gt;
                    &lt;/Columns&gt;
                    &lt;AlternatingRowStyle BackColor="#e9e9e9" /&gt;
                    &lt;HeaderStyle BackColor="#e9e9e9" ForeColor="#D71826" /&gt;
                    &lt;EmptyDataTemplate&gt;
                        Empty Gridview
                    &lt;/EmptyDataTemplate&gt;
                    &lt;EmptyDataRowStyle ForeColor="#D71826" /&gt;
                &lt;/asp:GridView&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;


    &lt;asp:SqlDataSource ID="ds_AccountCode" runat="server" ConnectionString="&lt;%$ ConnectionStrings:TOA_LIVEConnectionString %&gt;"
        SelectCommand="SELECT [toa_account_name] FROM [toa_AccountCode]"&gt;&lt;/asp:SqlDataSource&gt;


    &lt;asp:SqlDataSource ID="ds_Department" runat="server" ConnectionString="&lt;%$ ConnectionStrings:TOA_LIVEConnectionString %&gt;"
        SelectCommand="SELECT [toa_businessDepartment] FROM [toa_Department]"&gt;&lt;/asp:SqlDataSource&gt;


    &lt;asp:SqlDataSource ID="ds_businessLocation" runat="server" ConnectionString="&lt;%$ ConnectionStrings:TOA_LIVEConnectionString %&gt;"
        SelectCommand="SELECT [toa_site] FROM [toa_Location]"&gt;&lt;/asp:SqlDataSource&gt;
&lt;/asp:Content&gt;
</code></pre>

<p>C#</p>

<pre><code>protected void btnApprove_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow row in gvCreditCards.Rows)
        {
            string id = row.Cells[0].Text;
            TextBox tDESCRIPTION = (TextBox)row.FindControl("txtUserDescription");
            string sDESCRIPTION = tDESCRIPTION.Text;
            DropDownList ddlRECEIPT = (DropDownList)row.FindControl("ddlReceipt");
            string sRECEIPT = ddlRECEIPT.SelectedValue;
            DropDownList ddlGLCODE = (DropDownList)row.FindControl("ddlGLCode");
            string sDDLCODE = ddlGLCODE.SelectedValue;
            DropDownList ddlDEPARTMENT = (DropDownList)row.FindControl("ddlDepartment");
            string sDEPARTMENT = ddlDEPARTMENT.SelectedValue;
            DropDownList ddlLOCATION = (DropDownList)row.FindControl("ddlLocation");
            string sLOCATION = ddlLOCATION.SelectedValue;

            foreach (var v in new object[] { sDESCRIPTION, sRECEIPT, sDDLCODE, sDEPARTMENT, sLOCATION })
            {
                if (v.ToString() == "")
                {
                    btnApproveSave_Click(sender, e);
                    Response.Redirect(string.Format("http://transovaapps/TransOvaApps/departments/Accounting/CreditCard/CreditCardApprovals.aspx?emptyValue=true"));
                }
            }
        }
</code></pre>