refreshing gridview to get latest values after update while using datasourceid
<p>So i have a gridview that runs a rowcommand to update values in the DB. everything works, except that after running the update the gridview does not refresh with the newest values of the table. I've seen many solutions to solve this problem, most of them stating simply, "just rebind the gridview"</p>

<p>I've tried just running the binding of the gridview, but this does nothing to refresh the gridview. 
I've also tried reassigning the datasource to the objectdatasource used when first creating the table like so:</p>

<pre><code>GridViewHolder.DataSource = MachineDataSet;
GridViewHolder.DataBind();
</code></pre>

<p>However, i ended up getting an error saying: that both datasource and the datasourceid is declared and to remove one definition.</p>

<p>I would appreciate it greatly if someone could tell me what i am doing wrong with my gridveiw?</p>

<p>below you will find my gridview and codebehind for the rowcommand.</p>

<p>gridview: note: i removed all the unnessary context to make it easier to read, if you require more information i will throw up the entire code for the gridview.</p>

<pre><code>&lt;asp:GridView ID="GridViewHolder" 
                      runat="server" 
                      AllowPaging="True" 
                      AutoGenerateColumns="False"                                                                             
                      EnableViewState="False"
                      DataKeyNames="ID"                          
                      OnRowCommand="GridViewHolder_RowCommand" 
                      DataSourceID="MachineDataSet"&gt;
            &lt;RowStyle BackColor="Transparent" 
                      HorizontalAlign="Center" /&gt;
            &lt;Columns&gt;                    
                &lt;asp:ButtonField ButtonType="Button" Text="Assign New Values" 
                                 CommandName="AssignNewValue" ItemStyle-Wrap="true"
                                 ItemStyle-Width="25px"&gt;
                    &lt;ItemStyle Width="25px" Wrap="True" /&gt;
                &lt;/asp:ButtonField&gt;
            &lt;/Columns&gt;
     &lt;/asp:GridView&gt;
</code></pre>

<p>codebehind:</p>

<pre><code>/// &lt;summary&gt;
    /// Handles the rowcommand event button
    /// &lt;/summary&gt;
    /// &lt;param name="sender"&gt;The source control event&lt;/param&gt;
    /// &lt;param name="e"&gt;The &lt;see cref="System.Web.UI.WebControls.GridViewCommandEventArgs"/&gt; instance containing the even data.&lt;/param&gt;
    protected void GridViewHolder_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        logger.Debug("Entering Row Command");
        if (e.CommandName.CompareTo("AssignNewValue") == 0)
        {
            try
            {

                logger.Debug("Entering AssignNewValue Command");
                int index = Convert.ToInt32(e.CommandArgument);
                GridView gv = (GridView)Panel1.FindControl("GridViewHolder");
                GridViewRow row = gv.Rows[index];
                Label machineID = (Label)row.FindControl("MachineIDLabel");
                int machineid = Convert.ToInt32(machineID.Text);
                string machinetypeid = MachineTypeComboBox.SelectedValue;
                string machinemodelid = MachineModelComboBox.SelectedValue;
                try
                {
                    if (machinetypeid != "" || machinemodelid != "")
                    {
                        if (machinetypeid != "")
                        {
                            inputsService.UpdateMachineTypes(machineid, machinetypeid);
                        }
                        if (machinemodelid != "")
                        {
                            inputsService.UpdateMachineModels(machineid, machinemodelid);
                        }

                        UpdateSucceed.Visible = true;
                        logger.Debug("AssignNewValue - Database successfully updated!");
                    }
                    else
                    {
                        UpdateFail.Visible = true;
                        logger.Debug("AssignNewValue - Database had no data selected to be updated.");
                    }                        
                }
                catch (Exception ex)
                {
                    logger.ErrorFormat("AssignNewValue - Failed to update the table, ex = {0}", ex);
                }

            }
            catch (Exception ex)
            {
                logger.ErrorFormat("AssignNewValue Failed to complete, {0}", ex);
            }

            logger.Debug("Leaving AssignNewValue Command");
        }
        logger.Debug("Leaving Row Command");
    }
</code></pre>

<p>Datasource code:</p>

<pre><code>&lt;asp:ObjectDataSource ID="MachineDataSet"
                               runat="server" 
                               SelectMethod="GetMachineSiteDetails"                                                          
                               TypeName="Datamart.UI.Reporting.Web.FilteredReportInputsSvc.FilteredReportInputsService" 
                               EnableCaching="True"&gt;
             &lt;SelectParameters&gt;
                 &lt;asp:Parameter DefaultValue="" Name="siteid" Type="String" /&gt;
             &lt;/SelectParameters&gt;
         &lt;/asp:ObjectDataSource&gt; 
</code></pre>

<p>any help or suggestions are greatly appreciated.</p>

<p>Thanks</p>
