title: Make text appear in a textbox when clicking on button
body: <p>I have some text which I want to appear in a textbox which I click on the linkbutton "Edit"
  As you can see I have <code>CommandNames</code> and <code>CommandArguments</code> on those linkbuttons so I need a solution which can be written in the codebehind (.cs) as I got an <code>if (e.CommandName == "Edit")</code></p>
  
  <p>I haven't tried anything, as I can't find anything about it, neither in my head.</p>
  
  <h2>Designer Code:</h2>
  
  <pre><code>&lt;asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" OnItemCommand="Repeater1_ItemCommand"&gt;
      &lt;asp:ItemTemplate&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;asp:TextBox ID="TextBox_Text" runat="server" Text='&lt;%# Eval("Text") %&gt;'&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:LinkButton ID="LinkButton_Save" runat="server" CommandName="Save" CommandArgument='&lt;%# Eval("Id") %&gt;'&gt; Save &lt;/asp:LinkButton&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:LinkButton ID="LinkButton_Edit" runat="server" CommandName="Edit" CommandArgument='&lt;%# Eval("Id") %&gt;'&gt; Edit &lt;/asp:LinkButton&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:LinkButton ID="LinkButton_Delete" runat="server" CommandName="Delete" CommandArgument='&lt;%# Eval("Id") %&gt;'&gt; Delete &lt;/asp:LinkButton&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/asp:ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  
  &lt;asp:SqlDataSource runat="server" ID="SqlDataSource_Forside" ConnectionString='&lt;%$ ConnectionStrings:ConnectionString %&gt;' SelectCommand="SELECT * FROM [Table1]"&gt; &lt;asp:SqlDataSource&gt;
  </code></pre>
  
  <p><br /></p>
  
  <p><h2>Code behind:</h2></p>
  
  <p><br /></p>
  
  <pre><code>if (e.CommandName == "Edit")
      {
          SqlConnection conn = new SqlConnection();
          conn.ConnectionString =
              ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
  
          SqlCommand cmd = new SqlCommand();
          cmd.Connection = conn;
          cmd.CommandText = "Select * FROM Table1 WHERE Id = @Id";
  
  
          cmd.Parameters.Add("@Id", SqlDbType.Int).Value = e.CommandArgument.ToString();
  
          conn.Open();
          SqlDataReader reader = cmd.ExecuteReader();
  
          if (reader.Read())
          {
              TextBox_Edit.Text = reader["Text"].ToString(); // i dont have the textbox yet..
          }
          conn.Close();
  
          Repeater1.DataBind();
  
      }
  </code></pre>