title: Bind Data not shown in grid
body: <p>In the below code, I am successfully getting 369 records in the options list:</p>
  <pre><code>  public ArrayList GetOptionsChain(string ticker)
  {
      ticker = CorrectSymbol(ticker);
      string url;
      if (ticker.StartsWith(&quot;^&quot;))
          url = string.Format(@&quot;http://www.nseindia.com/live_market/dynaContent/live_watch/option_chain/optionKeys.jsp?symbol={0}&amp;instrument=OPTIDX&amp;date=-&quot;, ticker.TrimStart(new char[] { '^' }));
      else
          url = string.Format(@&quot;http://npg.veh.mybluehostin.me:8000/symbols/?name={0}&quot;, ticker.TrimStart(new char[] { '^' }));
  
      ArrayList options_list = new ArrayList();
      try
      {
          XDocument xml = XDocument.Load(url);
  
          var nodes1 = (from n in xml.Descendants(&quot;oc&quot;).Descendants(&quot;row&quot;)
                        select new
                        {
                            type = (string)n.Element(&quot;type&quot;).Value,
                            symbol = (string)n.Element(&quot;symbol&quot;).Value,
                            expiration = (string)n.Element(&quot;expiration&quot;).Value,
                            strike = (string)n.Element(&quot;strike&quot;).Value,
                            bid = (string)n.Element(&quot;bid&quot;).Value,
                            ask = (string)n.Element(&quot;ask&quot;).Value,
                            last = (string)n.Element(&quot;last&quot;).Value,
                            change = (string)n.Element(&quot;change&quot;).Value,
                            totalvol = (string)n.Element(&quot;totalvol&quot;).Value,
                            open_int = (string)n.Element(&quot;open_int&quot;).Value,
                            chng_open_int = (string)n.Element(&quot;chng_open_int&quot;).Value
                        }).ToList();
  
  
  
  
          foreach (var n in nodes1)
          {
              Option option = new Option();
  
              // option stock ticker and number of stocks per contract
              option.stock = ticker;
              option.stocks_per_contract = 1;
              option.update_timestamp = DateTime.Now;
              option.type = n.type;
              // symbol
              option.symbol = n.symbol; //&quot;.&quot; + symbol_href.Replace(&quot;javascript:chartPopup(&quot;, &quot;&quot;).Replace(&quot;);&quot;, &quot;&quot;).Replace(&quot; &quot;, &quot;&quot;).Replace(&quot;,&quot;, &quot;&quot;).Replace(&quot;.&quot;, &quot;&quot;).Replace(&quot;'&quot;, &quot;&quot;);
  
              // expiration date
              DateTime.TryParse(n.expiration, ci, DateTimeStyles.None, out option.expiration);
  
              // strike price
              double.TryParse(n.strike, NumberStyles.Number, ci, out option.strike);
  
              // option bid price                    
              option.price.bid = double.NaN;
              double.TryParse(n.bid, NumberStyles.Number, ci, out option.price.bid);
  
              // option ask price
  
              option.price.ask = double.NaN;
              double.TryParse(n.ask, NumberStyles.Number, ci, out option.price.ask);
  
              // option last price
  
              option.price.last = double.NaN;
              double.TryParse(n.last, NumberStyles.Number, ci, out option.price.last);
  
              // option price change
  
              option.price.change = double.NaN;
              double.TryParse(n.change, NumberStyles.Number, ci, out option.price.change);
  
              // option volume
  
              option.volume.total = 0;
              double.TryParse(n.totalvol, NumberStyles.Number, ci, out option.volume.total);
  
              // open int
  
              option.open_int = 0;
              int.TryParse(n.open_int, NumberStyles.Number, ci, out option.open_int);
  
              options_list.Add(option);
          }
  
      }
      catch (Exception ex)
      {
  
      }
  
      return options_list;
  
  }
  </code></pre>
  <p>But, it won't load the data on grid. The below code is used to show data on screen:</p>
  <pre><code>private void UpdateOptionsTable(string stock, Quote quote)
      { 
          // get stock's option list
          ArrayList list = Comm.Server.GetOptionsChain(stock);
          if (list == null || list.Count == 0) return;
  
          // begin data load
          OptionsTable.BeginLoadData();
  
          try
          {
              foreach (Option option in list)
              {
                  // update time-value
                  if (quote != null) option.price.timevalue = Algo.Model.TimeValue(quote.price.last, option);
  
                  // add option to table
                  AddOptionEntry(quote, option);
              }
          }
          catch { }
  
          // end data load
          OptionsTable.EndLoadData();
      }
  </code></pre>
  <p>This is the addoptionentry definition:</p>
  <pre><code>private OptionsTableRow GetOptionsTableRow()
      {
          if(OptionsTable.Rows.Count == 0)
          {
              OptionsTableRow row = OptionsTable.NewOptionsTableRow();
              OptionsTable.Rows.Add(row);
              row.AcceptChanges();
          }
  
          return (OptionsTableRow)OptionsTable.Rows[0];
      }
  private void AddOptionEntry(Quote quote, Option option)
      {
          bool new_row = false;
          OptionsTableRow row = GetOptionsTableRow();
  
          // make sure the option is in the future
          //if (option.expiration &gt; DateTime.Now.AddDays(-3)) return;
  
          if (!OptionsTable.Rows.Contains(option.symbol))
          {
              row = GetOptionsTableRow();
              new_row = true;
  
              try
              {
                  row.Symbol = option.symbol;
              }
              catch { }
          }
          else
          {
              row = OptionsTable.FindBySymbol(option.symbol);
              row.BeginEdit();
          }
  
          try
          {
              row.Type = option.type;
              row.Strike = option.strike;
              row.Expiration = DateTime.Parse(option.expiration.ToShortDateString());
  
              if (!double.IsNaN(option.price.last)) row.Last = option.price.last;
              else row.SetLastNull();
  
              if (!double.IsNaN(option.price.change)) row.Change = option.price.change;
              else row.SetChangeNull();
  
              if (!double.IsNaN(option.price.timevalue)) row.TimeValue = option.price.timevalue;
              else row.SetTimeValueNull();
  
              if (!double.IsNaN(option.price.bid)) row.Bid = option.price.bid;
              else row.SetBidNull();
  
              if (!double.IsNaN(option.price.ask)) row.Ask = option.price.ask;
              else row.SetAskNull();
  
              row.Volume = option.volume.total;
              row.OpenInt = option.open_int;
              row.Stock = option.stock;
              row.UpdateTimeStamp = option.update_timestamp;
              row.StocksPerContract = option.stocks_per_contract;
  
              if (option.type == &quot;Call&quot;)
              {
                  if (option.strike &gt; quote.price.last * 1.02) row.TheMoney = &quot;OTM&quot;;
                  else if (option.strike &lt; quote.price.last * 0.98) row.TheMoney = &quot;ITM&quot;;
                  else if (option.strike == quote.price.last) row.TheMoney = &quot;ATM&quot;;
                  else if (option.strike &gt; quote.price.last) row.TheMoney = &quot;ATM,OTM&quot;;
                  else if (option.strike &lt; quote.price.last) row.TheMoney = &quot;ATM,ITM&quot;;
              }
              else
              {
                  if (option.strike &gt; quote.price.last * 1.02) row.TheMoney = &quot;ITM&quot;;
                  else if (option.strike &lt; quote.price.last * 0.98) row.TheMoney = &quot;OTM&quot;;
                  else if (option.strike == quote.price.last) row.TheMoney = &quot;ATM&quot;;
                  else if (option.strike &gt; quote.price.last) row.TheMoney = &quot;ATM,ITM&quot;;
                  else if (option.strike &lt; quote.price.last) row.TheMoney = &quot;ATM,OTM&quot;;
              }
  
              option.greeks = Algo.Model.Greeks(quote, option, Config.Local.FederalIterest, StockDividendRate, double.NaN, double.NaN);
  
              row.ImpliedVolatility = option.greeks.implied_volatility;
              row.Delta = option.greeks.delta;
              row.Gamma = option.greeks.gamma;
              row.Vega = option.greeks.vega;
              row.Theta = option.greeks.theta;
          }
          catch { }
  
          try
          {
              // add row to table (if new)
              if (new_row) OptionsTable.Rows.Add(row);
          }
          catch { }
  
          // save option in cache
          if (option_cache.ContainsKey(option.symbol)) option_cache[option.symbol] = option;
          else option_cache.Add(option.symbol, option);
      }
  </code></pre>
  <p>This is where I am calling updateoptionstable:</p>
  <pre><code>public void Update(string stock)
      {
          // update quote table
          Quote quote = null;
  
          try
          {
              // update quote data base
              quote = UpdateQuotesTable(stock);
          }
          catch { }
  
          if (quote != null)
          {
              try
              {
                  // update database version and creation date
                  Version = Config.Local.CurrentVersion;
                  DatabaseCreationDate = DateTime.Now;
                  UpdateDate = DateTime.Now;
  
                  // update options table
                  UpdateOptionsTable(quote.stock, quote);
  
                  // update conversion tables
                  UpdateConversionTables();
  
                  // update historical volatility              
                  if ((Config.Local.GetParameter(&quot;Volatility Mode&quot;) == &quot;Stock HV&quot;) ||
                      (Config.Local.GetParameter(&quot;Download Historical Volatility&quot;) == &quot;Yes&quot;))
                  {
                      UpdateHistoricalVolatility(quote.stock);
                  }
  
                  // update derived data
                  UpdateDerivedData(quote, true, true, true, true);
              }
              catch { }
          }
      } 
  </code></pre>
  <p>and in the end the update function is used  by :</p>
  <pre><code>private void downloadWorker_DoWork(object sender, DoWorkEventArgs e)
      {
          // update stock data
          core.Update(stockText.Text);
  
          // update interset rate if (auto update is enabled)
          if (Config.Local.GetParameter(&quot;Federal Interest Auto Update&quot;) == &quot;Enabled&quot;)
          {
              Config.Local.SetInterest(&quot;Federal&quot;, Comm.Server.GetAnnualInterestRate(1.0));
          }
      }
  </code></pre>
  <p>Rest of the things is being shown in the grid but neither I am getting any error nor this data was able to populate on the screen. Can someone please review and correct me if I am doing anything wrong here.</p>
  <p>These are the datatable and bindingsource I am using in the code:</p>
  <pre><code>    //Initialize Components
  
  this.optionsTableBindingSource = new System.Windows.Forms.BindingSource(this.components);
  
  
  ((System.ComponentModel.ISupportInitialize)(this.optionsDataGridView)).BeginInit();
              ((System.ComponentModel.ISupportInitialize)(this.optionsTableBindingSource)).BeginInit();
              this.optionSelectionGroupBox1.SuspendLayout();
              this.optionSelectionGroupBox3.SuspendLayout();
              this.optionSelectionGroupBox2.SuspendLayout();
              this.optionSelectionGroupBox4.SuspendLayout();
              this.stockGroupBox.SuspendLayout();
  
  
              this.optionsDataGridView.DataSource = this.optionsTableBindingSource;
  // optionsTableBindingSource
              // 
              this.optionsTableBindingSource.DataMember = &quot;OptionsTable&quot;;
              this.optionsTableBindingSource.DataSource = this.optionsSet;
  #MainForms
  ((System.ComponentModel.ISupportInitialize)(this.optionsDataGridView)).EndInit();
          ((System.ComponentModel.ISupportInitialize)(this.optionsTableBindingSource)).EndInit();
          this.optionSelectionGroupBox1.ResumeLayout(false);
          this.optionSelectionGroupBox3.ResumeLayout(false);
          this.optionSelectionGroupBox2.ResumeLayout(false);
          this.optionSelectionGroupBox4.ResumeLayout(false);
          this.stockGroupBox.ResumeLayout(false);
          this.stockGroupBox.PerformLayout();
  </code></pre>
  <p>and this is how updatebuttonclick event works:</p>
  <pre><code>private void updateButton_Click(object sender, EventArgs e)
      {
          // execute only once
          if (downloadWorker.IsBusy) return;
  
          // clear database if symbol is new
          if (updateButton.Text == &quot;Update&quot;) newButton_Click(sender, e);
  
          // show download message
          updateButton.Visible = false;
          autoRefreshCheckBox.Visible = false;
          serverProgressBar.Value = 0;
          serverProgressBar.Visible = false;
          progressLabel.Visible = false;
          downloadLabel.Visible = true;            
  
          // control tour progress
          if (balloonForm.Active) balloonForm.Hide();
  
          // suspend binding
          optionsTableBindingSource.SuspendBinding();
          optionsTableBindingSource.RaiseListChangedEvents = false; 
  
          positionsTableBindingSource.SuspendBinding();
          positionsTableBindingSource.RaiseListChangedEvents = false; 
  
          resultsTableBindingSource.SuspendBinding();
          resultsTableBindingSource.RaiseListChangedEvents = false; 
  
          // run worker
          downloadWorker.RunWorkerAsync();
      }
  </code></pre>