How to update the status of one value in the GridView using the DropDownList?
<p>I have two tables in my database as following:</p>

<p>Suggestions Table: ID, Title, Description, StatusID... etc</p>

<p>SuggestionsStatus Table: ID, Status</p>

<p>I am using GridView to show the Suggestions and in the last column I put a DropDownList that for selecting the status for each Suggestion. Now, when I tried to update the Status of one of the submitted suggestions by selecting the status from the DropDownList, the value has been selected but it was updated but for all suggestions and I don't know why</p>

<p>My ASP.NET code:</p>

<pre><code>&lt;asp:GridView ID="GridView1" runat="server" AllowPaging="True"
                        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID"
                        width="950px" CssClass="mGrid"
                        AlternatingRowStyle-CssClass="alt"
                        RowStyle-HorizontalAlign="Center"
                        DataSourceID="SqlDataSource1"
                        OnRowDataBound="GridView1_RowDataBound" &gt;
            &lt;AlternatingRowStyle BackColor="White" ForeColor="#284775" /&gt;
            &lt;HeaderStyle Font-Bold = "true" ForeColor="Black" Height="20px"/&gt;
            &lt;Columns&gt;
                &lt;asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
                    ReadOnly="True" SortExpression="ID" /&gt;
                &lt;asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /&gt;
                &lt;asp:BoundField DataField="Description" HeaderText="Description"
                    SortExpression="Description" /&gt;
                &lt;asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /&gt;
                &lt;asp:BoundField DataField="Username" HeaderText="Username"
                    SortExpression="Username" /&gt;
                &lt;asp:BoundField DataField="DivisionShortcut" HeaderText="Division"
                    SortExpression="DivisionShortcut" /&gt;
                &lt;asp:TemplateField HeaderText="Status"&gt;
                    &lt;ItemTemplate&gt;
                        &lt;asp:DropDownList ID="DropDownList" runat="server" DataSourceID="SqlDataSource2"
                                          Font-Bold="True" ForeColor="#006666" AppendDataBoundItems="false"
                                          DataTextField="Status" DataValueField="ID" AutoPostBack="true"
                                          OnDataBound="DropDownList_DataBound"&gt;
                        &lt;/asp:DropDownList&gt;
                    &lt;/ItemTemplate&gt;
                &lt;/asp:TemplateField&gt;
            &lt;/Columns&gt;
        &lt;/asp:GridView&gt;
        &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="&lt;%$ ConnectionStrings:testConnectionString %&gt;"
            SelectCommand="SELECT     dbo.SafetySuggestionsLog.ID, dbo.SafetySuggestionsLog.Title, dbo.SafetySuggestionsLog.Description, dbo.employee.Name, dbo.SafetySuggestionsLog.Username,
                      dbo.Divisions.DivisionShortcut
FROM         dbo.employee INNER JOIN
                      dbo.SafetySuggestionsLog ON dbo.employee.Username = dbo.SafetySuggestionsLog.Username INNER JOIN
                      dbo.Divisions ON dbo.employee.DivisionCode = dbo.Divisions.SapCode"
                      FilterExpression="[DivisionShortcut] like '{0}%'"&gt;

                      &lt;FilterParameters&gt;
                        &lt;asp:ControlParameter ControlID="ddlDivision" Name="DivisionShortcut"
                                                 PropertyName="SelectedValue" Type="String" /&gt;
                    &lt;/FilterParameters&gt;
        &lt;/asp:SqlDataSource&gt;

        &lt;%--For the DropDownList--%&gt;
        &lt;asp:SqlDataSource ID="SqlDataSource2" runat="server"
        ConnectionString="&lt;%$ ConnectionStrings:testConnectionString %&gt;"
        SelectCommand="SELECT * FROM [SafetySuggestionsStatus]"&gt;&lt;/asp:SqlDataSource&gt;
</code></pre>

<p>My Code-Behind:</p>

<pre><code>protected void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList ddl = (DropDownList)sender;
        int suggestionStatus = int.Parse(ddl.SelectedValue);

        //For inserting the status in the database
        string connString = "Data Source=localhost\\sqlexpress;Initial Catalog=psspdbTest;Integrated Security=True";
        string updateCommand = "UPDATE SafetySuggestionsLog  SET [StatusID] = @StatusID WHERE [ID] = @ID";
        using (SqlConnection conn = new SqlConnection(connString))
        {
            conn.Open();
            using (SqlCommand cmd = new SqlCommand(updateCommand, conn))
            {
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@StatusID", suggestionStatus);
                cmd.ExecuteNonQuery();
            }
            conn.Close();
        }
    }
</code></pre>

<p>** EDIT:**</p>

<p>I modified the <code>DropDownList_SelectedIndexChanged()</code> as shown above but the problem now is:</p>

<p>when I tried to update the status of one of the suggestions, then the status of all suggestions will be updated and I don't know why</p>

<p>So how I can fix this problem to be able to update the status of one of the submitted Suggestions in the (GridView) in the database?**</p>
