Gridview remove selected row
<p>I want to remove the selected gridview row when updating but don't really know how to do it.</p>

<p>My update code:</p>

<pre><code>    //Update selected assignment
    protected void ButtonUpdateAssignmentClick(object sender, EventArgs e)
    {           
        try
        {
            using (var db = new KnowItCvdbEntities())
            {
                SPWeb theSite = SPControl.GetContextWeb(Context);
                SPUser theUser = theSite.CurrentUser;
                string strUserName = theUser.LoginName;

                var theEmplAssignment = (
                                                from p
                                                    in db.EMPLOYEES
                                                where p.username == strUserName
                                                select p).FirstOrDefault();

                _emp = theEmplAssignment;

                if (_emp != null)
                {
                    int assignmentId = Convert.ToInt32(HiddenField_Assignment_Id.Value);

                    var theEmplAssignmentName =
                                                (from p in db.EMPLOYEES_ASSIGNMENT
                                                 where p.employee_id == _emp.employee_id &amp;&amp; p.assignment_id == assignmentId
                                                 select p).First();

                    if (theEmplAssignmentName != null)
                    {
                        theEmplAssignmentName.company_name = TextBoxCompanyName.Text;
                        theEmplAssignmentName.sector = TextBoxSector.Text;
                        theEmplAssignmentName.area = TextBoxArea.Text;
                        theEmplAssignmentName.from_date = TextBoxFromDate.Text;
                        theEmplAssignmentName.to_date = TextBoxToDate.Text;
                        theEmplAssignmentName.reference_name = TextBoxReference.Text;
                        theEmplAssignmentName.description = TextBoxDesc.Text;

                        db.SaveChanges();

                        //Populate gridview 
                        if (Session["DataTableAssignment"] != null)
                        {
                            _dt = (DataTable)Session["DataTableAssignment"];
                        }
                        else
                        {
                            _dt.Columns.Add("Company name");
                            _dt.Columns.Add("Sector");
                            _dt.Columns.Add("Area");
                            _dt.Columns.Add("From");
                            _dt.Columns.Add("To");
                            _dt.Columns.Add("Tools");
                            _dt.Columns.Add("Technology");
                            _dt.Columns.Add("Description");
                            _dt.Columns.Add("Reference");
                            _dt.Columns.Add("AssignmentId");
                        }
                        //dt.Rows.Clear();

                        DataRow dr = _dt.NewRow();
                        dr["Company name"] = theEmplAssignmentName.company_name;
                        dr["Sector"] = theEmplAssignmentName.sector;
                        dr["Area"] = theEmplAssignmentName.area;
                        dr["From"] = theEmplAssignmentName.from_date;
                        dr["To"] = theEmplAssignmentName.to_date;
                        dr["Description"] = theEmplAssignmentName.description;
                        dr["Reference"] = theEmplAssignmentName.reference_name;
                        dr["AssignmentId"] = theEmplAssignmentName.assignment_id;

                        List&lt;ASSIGNMENT_TOOLS&gt; assignmentTools = (from p in db.ASSIGNMENT_TOOLS
                                                                  where
                                                                      p.employee_id == _emp.employee_id &amp;&amp;
                                                                      p.assignment_id == assignmentId
                                                                  select p).ToList();

                        string sToolValue = string.Empty;
                        foreach (var vTool in assignmentTools)
                        {
                            sToolValue += vTool.tool_name + ", ";
                        }
                        dr["Tools"] = sToolValue;


                        List&lt;ASSIGNMENT_TECHNOLOGY&gt; assignmentTech = (from p in db.ASSIGNMENT_TECHNOLOGY
                                                                      where
                                                                          p.employee_id == _emp.employee_id &amp;&amp;
                                                                          p.assignment_id == assignmentId
                                                                      select p).ToList();

                        string sTechValue = string.Empty;
                        foreach (var vTech in assignmentTech)
                        {
                            sTechValue += vTech.technology_name + ", ";
                        }
                        dr["Technology"] = sTechValue;

                        _dt.Rows.Add(dr);
                        Session["DataTableAssignment"] = _dt;

                        GridViewShowAssignments.DataSource = _dt;
                        GridViewShowAssignments.DataBind();

                        TextBoxCompanyName.Text = string.Empty;
                        TextBoxSector.Text = string.Empty;
                        TextBoxArea.Text = string.Empty;
                        TextBoxFromDate.Text = string.Empty;
                        TextBoxToDate.Text = string.Empty;
                        TextBoxDesc.Text = string.Empty;
                        TextBoxReference.Text = string.Empty;
                        ListBoxAssignmentTools.Items.Clear();
                        ListBoxAssignmentTechnology.Items.Clear();
                    }
                }
            }
        }
        catch (Exception x)
        {
            LabelProvAssignment.Text = x.Message;
        }
    }
</code></pre>

<p>Right now I got one assignment and want to edit it, I click on edit, enter some new values and click on Update:
<img src="http://i.stack.imgur.com/kL9ct.jpg" alt="enter image description here"></p>

<p>But when the update is finished the following is shown:
<img src="http://i.stack.imgur.com/iHARU.jpg" alt="enter image description here"></p>
