title: The name ' ' does not exist in the current context
body: <p>The name 'Label2.Text' does not exist in the current context
  Catalog.aspx</p>
  
  <pre><code> &lt;asp:DataList ID="DataList1" runat="server" DataKeyField="Id" DataSourceID="SqlDataSource1" RepeatColumns="4" RepeatLayout="Flow"&gt;
      &lt;ItemTemplate&gt;
          &lt;div class="Item"&gt;
              &lt;div class="name"&gt;
                  &lt;asp:Label ID="NameLabel" runat="server" Text='&lt;%# Eval("Name") %&gt;' /&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  Код:&lt;asp:Label ID="Label2" runat="server" Text='&lt;%# Eval("Id") %&gt;' /&gt;
              &lt;/div&gt;
              &lt;img src="&lt;%# Eval("Image") %&gt;" height="115" alt="item"/&gt;
              &lt;div class="price"&gt;
                  Цена:
  
                  &lt;asp:Label ID="PriceLabel" runat="server" Text='&lt;%# Eval("Price")%&gt;' /&gt;p.
                  &lt;asp:Button ID="Button2" runat="server" ForeColor="Black" 
                      onclick="Button2_Click" Text="В КОРЗИНУ" /&gt;
              &lt;/div&gt;
              &lt;div class="desc"&gt;
                  &lt;asp:Label ID="DescriptionLabel" runat="server" Text='&lt;%# Eval("Description") %&gt;' /&gt;
  
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:DataList&gt;
  </code></pre>
  
  <p>Catalog.aspx.cs</p>
  
  <pre><code>sqlCon.Open();
  SqlCommand cmd_SQL = new SqlCommand("INSERT INTO Cart(ClientId,ProductId,Amount) VALUES (@ClientId,@ProductId,@Amount)", sqlCon);
  cmd_SQL.Parameters.Add("@ClientId", SqlDbType.NVarChar).Value =Membership.GetUser().ProviderUserKey.ToString();
  cmd_SQL.Parameters.Add("@ProductId", SqlDbType.NVarChar).Value =Label2.Text;
  cmd_SQL.Parameters.Add("@Amount", SqlDbType.NVarChar).Value = 1;
  
  cmd_SQL.CommandType = CommandType.Text;
  cmd_SQL.ExecuteNonQuery();
  </code></pre>
  
  <p>The name 'Label2.Text' does not exist in the current context</p>