title: Unable to cast object of type ‘System.Web.UI.LiteralControl’ Error
body: <p>I am getting this error:
  Unable to cast object of type ‘System.Web.UI.LiteralControl’ to type ‘System.Web.Controls.TextBox’</p>
  
  <p>I am feeding my Text input box from a querystring in the ASPX page and here is the code:</p>
  
  <pre><code>&lt;EditItemTemplate&gt;
                          &lt;asp:TextBox ID="GV_Post_ID" runat="server" text='&lt;%# Request.QueryString["Post_ID"] %&gt;'&gt;&lt;/asp:TextBox&gt;
                      &lt;/EditItemTemplate&gt;
  </code></pre>
  
  <p>But when I run it, it stops here:</p>
  
  <pre><code>cmd.Parameters.Add("@Post_ID", SqlDbType.VarChar).Value = ((TextBox)GV_InlineEditing.Rows[0].Cells[2].Controls[0]).Text;
  </code></pre>
  
  <p>and I get the error above.  Here is the code behind:</p>
  
  <pre><code>SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DSRConnectionString"].ConnectionString);
              SqlCommand cmd = new SqlCommand();
              cmd.CommandText = "INSERT INTO RCA_Events(Post_ID, Date, Description) VALUES(@Post_ID, @Date, @Description)";
              cmd.Parameters.Add("@Post_ID", SqlDbType.VarChar).Value = ((TextBox)GV_InlineEditing.Rows[0].Cells[2].Controls[0]).Text;
              cmd.Parameters.Add("@Date", SqlDbType.VarChar).Value = ((TextBox)GV_InlineEditing.Rows[0].Cells[3].Controls[0]).Text;
              cmd.Parameters.Add("@Description", SqlDbType.VarChar).Value = ((TextBox)GV_InlineEditing.Rows[0].Cells[4].Controls[0]).Text;
  </code></pre>
  
  <p>Please note if I remove the querystring from the ASPX page and then I insert the value manually then it works.  Pls. help.
  thanks</p>