title: 'ddlItem' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value
body: <p>I'm getting this error whenever I try to bind data inside gridview dropdownlist.</p>
  
  <p>Here is the aspx code:</p>
  
  <pre><code>&lt;asp:TemplateField HeaderText="Item Description"  SortExpression="ddlItem"&gt;
         &lt;ItemTemplate&gt;
           &lt;asp:DropDownList ID="ddlItem" runat="server" Height="25px" Width="200px" SelectedValue='&lt;%# Eval("ddlItem") %&gt;'&gt;
           &lt;/asp:DropDownList&gt;
         &lt;/ItemTemplate&gt;
      &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>Here is the code behind (c#):</p>
  
  <pre><code>        private void SetInitialRowToGrid()
              {
                  // Initialize and Set initial row of Datatable
                  var tempDataTable = new DataTable();
                  tempDataTable.Columns.Add("lblId");
                  tempDataTable.Columns.Add("ddlItem");
                  tempDataTable.Columns.Add("txtUnit");
                  tempDataTable.Columns.Add("txtQty");
                  tempDataTable.Rows.Add("1", "", "", "");
  
                  // Store that datatable into viewstate
                  ViewState["TempTable"] = tempDataTable;
  
                  // Attach Gridview Datasource to datatable        
                  gvItemList.DataSource = tempDataTable;
                  gvItemList.DataBind(); //Here I'm getting the error.
              }
  
      protected void gvItemList_RowDataBound(object sender, GridViewRowEventArgs e)
          {
              if (e.Row.RowType == DataControlRowType.DataRow)
              {
                  DropDownList ddlItem = (e.Row.FindControl("ddlItem") as DropDownList);
                  Jilu1TableAdapters.tbl_ItemTableAdapter item;
                  item = new Jilu1TableAdapters.tbl_ItemTableAdapter();
                  DataTable dt = new DataTable();
                  dt = item.GetItems();
  
                  ddlItem.DataSource = dt;
                  ddlItem.DataTextField = "Item";
                  ddlItem.DataValueField = "Item";
                  ddlItem.DataBind();
                  ddlItem.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select an Item--", "0"));
              }
          }
  
  protected void ddlSiteID_SelectedIndexChanged(object sender, EventArgs e)
      {
          Jilu1TableAdapters.tbl_Jr_BOMTableAdapter ds;
          ds = new Jilu1TableAdapters.tbl_Jr_BOMTableAdapter();
  
          DataTable dt = new DataTable();
          dt = ds.GetVersion(ddlSiteID.SelectedValue);
  
          ddlVersion.DataSource = dt;
          ddlVersion.DataValueField = "Version";
          ddlVersion.DataTextField = "Version";
          ddlVersion.DataBind();
  
          int ver = Convert.ToInt32(ddlVersion.Text);
          DataTable dt1 = new DataTable();
  
          dt1 = ds.GetDetails(ddlSiteID.SelectedValue, ver);
  
          foreach (DataRow row in dt1.Rows)
          {
              txtSiteName.Text = (row["txtSiteName"].ToString());
              ddlSiteType.Text = (row["ddlSiteType"].ToString());
              txtNoBTS.Text = (row["txtNoBTS"].ToString());
              txtNoLinks.Text = (row["txtNoLinks"].ToString());
              txtLoadBand.Text = (row["txtLoadBand"].ToString());
              ddlEBAvailability.Text = (row["ddlEBAvailability"].ToString());
              txtEBPhase.Text = (row["txtEBPhase"].ToString());
              txtDGCapacity.Text = (row["txtDGCapacity"].ToString());
              txtDGPhase.Text = (row["txtDGPhase"].ToString());            
          }
          gvItemList.DataSource = dt1;
          gvItemList.DataBind();
      }
  </code></pre>
  
  <p>I tried putting <code>Text = 'Bind("ddlItem")', Datasourse, SelectedValue</code> but still no luck.</p>
  
  <p>Any help will be greatly appreciated. </p>