title: dropdownlist in edititemtemplate gridview asp.net
body: <p>I have one problem with a gridview control and maybe someone can help me.<br>
  In the gridview, there is a field <code>Country</code> which comes from the database.<br>
  I have enabled editing the data in the gridview, and when someone will click the gridview edit button, the gridview will come up and offer them to select the new value for that field.</p>
  
  <p>But when I am clicking Edit, I am getting this error : </p>
  
  <blockquote>
    <p>'Type 'System.Web.UI.WebControls.ListItem' in Assembly 'System.Web, Version=4.0.0.0,  Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.'</p>
  </blockquote>
  
  <p>Here is the code I have for that field, in shorter version, excluding most of the countries from the example:</p>
  
  <pre><code>&lt;asp:TemplateField HeaderText="Country" SortExpression="Country"&gt;
      &lt;ItemTemplate&gt;
          &lt;asp:Label ID="Label1" runat="server" 
                     Text='&lt;%# Bind("Country") %&gt;'&gt;
          &lt;/asp:Label&gt;
      &lt;/ItemTemplate&gt;
      &lt;EditItemTemplate&gt;
          &lt;asp:DropDownList id="ddlCountry" 
                            SelectedItem='&lt;%# Bind("Country") %&gt;' 
                            runat="server"&gt;
              &lt;asp:ListItem Value="N/A"&gt;Please select&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="US"&gt;United States&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="AF"&gt;Afghanistan&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="AL"&gt;Albania&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="DZ"&gt;Algeria&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="AS"&gt;American Samoa&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="AD"&gt;Andorra&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="AO"&gt;Angola&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="AI"&gt;Anguilla&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="AQ"&gt;Antarctica&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="AG"&gt;Antigua And Barbuda&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="AR"&gt;Argentina&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="AM"&gt;Armenia&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="AW"&gt;Aruba&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="AU"&gt;Australia&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="AT"&gt;Austria&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="ZR"&gt;Zaire&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Value="ZM"&gt;Zambia&lt;/asp:ListItem&gt;
             &lt;asp:ListItem Value="ZW"&gt;Zimbabwe&lt;/asp:ListItem&gt;   
          &lt;/asp:DropDownList&gt;
      &lt;/EditItemTemplate&gt;
  </code></pre>