GridView Edit/Delete Not refreshing correctly. ASP.Net
<p>Essentially what i'm doing is allowing a user to type in a persons name, press a button and edit/delete a field of choice.</p>

<p>I can edit/delete fine using the default gridview properties. But when I press edit, It reloads back to the default  selectcommand. What i need it to do is to use the textbox's text.</p>

<p>This is how i search for a user</p>

<pre><code> protected void GetUser_Click(object sender, EventArgs e)
    {
        query = Session["username"].ToString();  
        string sql = "SELECT [Username], [Job Description] AS Job_Description, [Hours Worked] AS Hours_Worked, [Date], [ID] FROM [TimeData] WHERE ([Username] LIKE '" + query+ "')";
        Response.Write("done");
        SqlDataSource1.SelectCommand = sql;
    }
</code></pre>

<p>So in the page loads i need it to " remember" what i put in before pressing edit.</p>

<p>in the ASPX file i leave the selectcommand blank, and instead set it in the Page_load method</p>

<pre><code> protected void Page_Load(object sender, EventArgs e)
    {
        GridView1.Visible = true;
        Session["Username"] = UserBox.Text;
        //Session["Username"] = "rhys";
        query = Session["username"].ToString();
        string sql = "SELECT [Username], [Job Description] AS Job_Description, [Hours Worked] AS Hours_Worked, [Date], [ID] FROM [TimeData]";
        //Response.Write("done");
        SqlDataSource1.SelectCommand = sql;   
    }
</code></pre>

<p>Atm I can get it to appear again, but i'm querying the full table again , not by username</p>

<p>I was looking at a way to maybe postback the variable or something but nothing seems to work.</p>

<p>Any help would be appreciated.</p>

<p>EDIT:
The comments have helped however the button I press</p>

<pre><code>  protected void GetUser_Click(object sender, EventArgs e)
 {
 query = Session["username"].ToString();
 string sql = "SELECT [Username], [Job Description] AS Job_Description, [Hours Worked] AS Hours_Worked, [Date], [ID] FROM   [TimeData] WHERE ([Username] LIKE '" + query + "')"; 
Response.Write("done");
 SqlDataSource1.SelectCommand = sql; 

} 
</code></pre>

<p>" No longer returns any changes , would that be because the same code is in the else part of the block after !postback?</p>
