title: How do I get the "@" value of a DropDownList when updating a DataGrid
body: <p>I have a standard DataGrid that looks like this:</p>
  
  <pre><code>&lt;asp:GridView id="MyGridView"
      DataSourceID="MyDataSource1"
    AutoGenerateColumns="false"
    AutoGenerateEditButton="true"
    DataKeyNames="Id"
  
      Runat="Server"&gt;
  
    &lt;Columns&gt;
  
    &lt;asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /&gt;
  
  
    &lt;asp:TemplateField HeaderText="State"&gt;
      &lt;ItemTemplate&gt;
        &lt;asp:Label ID="Label1" runat="server" Text='&lt;%# Bind("State") %&gt;'&gt;&lt;/asp:Label&gt;
      &lt;/ItemTemplate&gt;
  
      &lt;EditItemTemplate&gt;
        &lt;asp:DropDownList ID="IdState1"  DataSource='&lt;%# GetCategoryNames() %&gt;' DataTextField="State" DataValueField="State" runat="server"&gt;&lt;/asp:DropDownList&gt;
      &lt;/EditItemTemplate&gt;
  
    &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>When updating the grid I have an UpdateCommand that looks like this:</p>
  
  <pre><code>UpdateCommand= "UPDATE [MauriceBlackburnOffices] SET [Name] = @Name, [Address1] = @Address1, [TheStates] = @State WHERE [Id] = @Id"
  </code></pre>
  
  <p>However the @State field is not recognized.</p>
  
  <pre><code>Must declare the scalar variable "@State". 
  </code></pre>
  
  <p>What should the @ value be?</p>
  
  <p>How can I get the DropDownList value into the update statement?</p>