title: ASP.NET Error: Must declare the scalar variable
body: <p>I know I'm obviously missing / have improperly declared a variable but I'm not quite sure how to fix that. I am getting this error when ever I click "btnUpdate" to update the information in the database (based on whats in the text fields). I've posted the code below for review, thanks for the help!</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"     Inherits="WebApplication1.WebForm1" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form id="form1" runat="server"&gt;
  &lt;div&gt;
  
  &lt;div class="floater"&gt;
  &lt;h3&gt;Books&lt;/h3&gt;
  &lt;asp:DropDownList
      id="DropDownList_Books"
      DataSourceId="srcBooks"
      DataTextField="Title"
      DataValueField="Id"
      Runat="server" /&gt;
      &lt;asp:Button ID="btnSelect" runat="server" Text="View Detials" Width="106px" 
          onclick="btnSelect_Click" /&gt;
  &lt;/div&gt;
  
  &lt;asp:GridView
      id="grdBooks"
      DataSourceID="srcBooks_Description"
      Runat="server" Visible="False" /&gt;
  
      &lt;asp:Button ID="btnEdit" runat="server" onclick="btnEdit_Click" Text="Edit" /&gt;
  
  &lt;/div&gt;
  
  &lt;asp:Button ID="btnCancel" runat="server" onclick="btnCancel_Click" 
      style="z-index: 1; left: 464px; top: 153px; position: absolute; height: 26px" 
      Text="Cancel" Visible="False" /&gt;
  
  &lt;asp:FormView
      id="frmEditBook"
      DataKeyNames="Cat_Id"
      DataSourceId="srcBooks_Description"
      DefaultMode="Edit"
      Runat="server" Visible="False" 
      style="z-index: 1; left: 391px; top: 87px; position: absolute; height: 111px; width: 206px"&gt;
      &lt;EditItemTemplate&gt;
      &lt;asp:Label
          id="lblTitle"
          Text="Title:"
          AssociatedControlID="txtTitle"
          Runat="server" /&gt;
      &lt;asp:TextBox
          id="txtTitle"
          Text='&lt;%#Bind("Title")%&gt;'
          Runat="server" /&gt;
      &lt;br /&gt;
      &lt;asp:Label
          id="lblDescription"
          Text="Description:"
          AssociatedControlID="txtDescription"
          Runat="server" /&gt;
      &lt;asp:TextBox
          id="txtDescription"
          Text='&lt;%#Bind("Description")%&gt;'
          Runat="server" /&gt;
      &lt;br /&gt;
      &lt;asp:Button
          id="btnUpdate"
          Text="Update"
          CommandName="Update"
          Runat="server" /&gt;
      &lt;/EditItemTemplate&gt;
  &lt;/asp:FormView&gt;
  &lt;asp:SqlDataSource ID="srcBooks" runat="server" 
      ConnectionString="Data Source=&amp;quot;ebiz.isy.vcu.edu, 14330&amp;quot;;Initial Catalog=spring12u08;Persist Security Info=True;User ID=Spring12u08;Password=INFO451u08" 
      onselecting="srcBooks_Selecting" ProviderName="System.Data.SqlClient" SelectCommand="SELECT Title,Id FROM PARTIN_ID"&gt;
  
  &lt;/asp:SqlDataSource&gt;
  
  &lt;asp:SqlDataSource ID="srcBooks_Description" runat="server" 
      ConnectionString="Data Source=&amp;quot;ebiz.isy.vcu.edu, 14330&amp;quot;;Initial Catalog=spring12u08;Persist Security Info=True;User ID=Spring12u08;Password=INFO451u08" 
      onselecting="srcBooks_Selecting" ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM PARTIN_INFO WHERE Cat_ID=@Id" UpdateCommand="UPDATE PARTIN_INFO SET Title=@Title,
          Description=@Description WHERE Cat_Id=@Id"&gt;
  &lt;SelectParameters&gt;
          &lt;asp:ControlParameter
              Name="Id"
              Type="int32"                
              ControlID="DropDownList_Books" /&gt;
      &lt;/SelectParameters&gt;
  
  &lt;/asp:SqlDataSource&gt;
  
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Updated Code with new error: Could not find control 'txtTitle' in ControlParameter 'Title'.</p>
  
  <pre><code>&lt;form id="form1" runat="server"&gt;
  &lt;div&gt;
  
  &lt;div class="floater"&gt;
  &lt;h3&gt;Books&lt;/h3&gt;
  &lt;asp:DropDownList
      id="DropDownList_Books"
      DataSourceId="srcBooks"
      DataTextField="Title"
      DataValueField="Id"
      Runat="server" /&gt;
      &lt;asp:Button ID="btnSelect" runat="server" Text="View Detials" Width="106px" 
          onclick="btnSelect_Click" /&gt;
  &lt;/div&gt;
  
  &lt;asp:GridView
      id="grdBooks"
      DataSourceID="srcBooks_Description"
      Runat="server" Visible="False" /&gt;
  
      &lt;asp:Button ID="btnEdit" runat="server" onclick="btnEdit_Click" Text="Edit" /&gt;
  
  &lt;/div&gt;
  
  &lt;asp:Button ID="btnCancel" runat="server" onclick="btnCancel_Click" 
      style="z-index: 1; left: 464px; top: 153px; position: absolute; height: 26px" 
      Text="Cancel" Visible="False" /&gt;
  
  &lt;asp:FormView
      id="frmEditBook"
      DataKeyNames="Cat_Id"
      DataSourceId="srcBooks_Description"
      DefaultMode="Edit"
      Runat="server" Visible="False" 
  
      style="z-index: 1; left: 391px; top: 87px; position: absolute; height: 111px; width: 206px" &gt;
      &lt;EditItemTemplate&gt;
      &lt;asp:Label
          id="lblTitle"
          Text="Title:"
          AssociatedControlID="txtTitle"
          Runat="server" /&gt;
      &lt;asp:TextBox
          id="txtTitle"
          Text='&lt;%#Bind("Title")%&gt;'
          Runat="server" /&gt;
      &lt;br /&gt;
      &lt;asp:Label
          id="lblDescription"
          Text="Description:"
          AssociatedControlID="txtDescription"
          Runat="server" /&gt;
      &lt;asp:TextBox
          id="txtDescription"
          Text='&lt;%#Bind("Description")%&gt;'
          Runat="server" /&gt;
      &lt;br /&gt;
      &lt;asp:Button
          id="btnUpdate"
          Text="Update"
          CommandName="Update"
          Runat="server" /&gt;
      &lt;/EditItemTemplate&gt;
  &lt;/asp:FormView&gt;
  &lt;asp:SqlDataSource ID="srcBooks" runat="server" 
      ConnectionString="Data Source=&amp;quot;ebiz.isy.vcu.edu, 14330&amp;quot;;Initial Catalog=spring12u08;Persist Security Info=True;User ID=Spring12u08;Password=INFO451u08" 
      onselecting="srcBooks_Selecting" ProviderName="System.Data.SqlClient" SelectCommand="SELECT Title,Id FROM PARTIN_ID"&gt;
  
  &lt;/asp:SqlDataSource&gt;
  
  &lt;asp:SqlDataSource ID="srcBooks_Description" runat="server" 
      ConnectionString="Data Source=&amp;quot;ebiz.isy.vcu.edu, 14330&amp;quot;;Initial Catalog=spring12u08;Persist Security Info=True;User ID=Spring12u08;Password=INFO451u08" 
      onselecting="srcBooks_Selecting" ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM PARTIN_INFO WHERE Cat_ID=@Id" UpdateCommand="UPDATE PARTIN_INFO SET Title=@Title,
          Description=@Description WHERE Cat_Id=@Id"&gt;
  &lt;SelectParameters&gt;
          &lt;asp:ControlParameter
              Name="Id"
              Type="int32"                
              ControlID="DropDownList_Books"
              PropertyName="SelectedValue" /&gt;
      &lt;/SelectParameters&gt;
       &lt;UpdateParameters&gt;
            &lt;asp:ControlParameter Name="Title" ControlId="txtTitle" PropertyName="Text"/&gt;
            &lt;asp:ControlParameter Name="Description" ControlId="txtDescription" PropertyName="Text"/&gt;
            &lt;asp:ControlParameter Name="Id" ControlId="DropDownList_Books" PropertyName="SelectedValue"/&gt;
        &lt;/UpdateParameters&gt;
  
  &lt;/asp:SqlDataSource&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>Also code behind:</p>
  
  <pre><code>namespace WebApplication1
  {
  public partial class WebForm1 : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
  
      }
  
      protected void srcBooks_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
      {
  
      }
  
      protected void btnSelect_Click(object sender, EventArgs e)
      {
          grdBooks.Visible = true;
      }
  
      protected void btnCancel_Click(object sender, EventArgs e)
      {
          frmEditBook.Visible = false;
      }
  
      protected void btnEdit_Click(object sender, EventArgs e)
      {
          frmEditBook.Visible = true;
          btnCancel.Visible = true;
      }
  
      protected void btnUpdate_Click(object sender, EventArgs e)
      {
          try
          {
              srcBooks_Description.Update();
          }
          catch (Exception except)
          {
              // Handle the Exception.
          }
      }
  
  
  
  
  
  
      }
  }
  </code></pre>