title: Adding the text in a text box to a database table using OData and Knockout Js
body: <p>I am trying to add a value in some drop downs and text boxes to a table in sql database. Its works fine with the drop downs but with textboxes it adds NULL values to the table columns even though I have entered the values in the textboxes </p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;td&gt;
  
                  &lt;select data-bind="options: $root.locationNames, optionsText: 'LocationName', optionsValue: 'LocationName', value: selectedLocation, optionsCaption: 'Location'"&gt;
                  &lt;/select&gt;
              &lt;/td&gt;
  
              &lt;td&gt;
  
                  &lt;select data-bind="options: $root.pipelineNames, optionsText: 'PipelineName', optionsValue: 'PipelineName', value: selectedPipeline, optionsCaption: 'Pipeline'"&gt;
                  &lt;/select&gt;
              &lt;/td&gt;
  
  
              &lt;td&gt;
  
                  &lt;select data-bind="options: $root.counterpartyNames, optionsText: 'CounterPartyName', optionsValue: 'CounterPartyName', value: selectedBidCounterParty, optionsCaption: 'Bid CP'"&gt;
                  &lt;/select&gt;
              &lt;/td&gt;
  
  &lt;td&gt;
                  &lt;input type="text" name="bidVolume" data-bind="value: $root.BidVolume"/&gt;
              &lt;/td&gt;
  
              &lt;td&gt;
                  &lt;input type="text" name="bid" data-bind="value: $root.Bid"/&gt;
              &lt;/td&gt;
  
              &lt;td&gt;
                  &lt;input type="text" name="offer" data-bind="value: $root.Offer"/&gt;
              &lt;/td&gt;
  
              &lt;td&gt;
                  &lt;input type="text" name="offerVolume" data-bind="value: $root.OfferVolume"/&gt;
              &lt;/td&gt;
  &lt;td &gt;
                  &lt;input type="button" class="btn btn-success" data-bind="click: add, enable: selectedChoice" value="Add New Entry" /&gt;
              &lt;/td&gt;
  </code></pre>
  
  <p><strong>Knockout Js with OData</strong></p>
  
  <pre><code>self.selectedChoice = ko.observable();
      self.selectedTerm = ko.observable();
      self.selectedLocation = ko.observable();
      self.selectedPipeline = ko.observable();
      self.selectedIndex = ko.observable();
      self.selectedBidCounterParty = ko.observable();
      self.selectedOfferCounterParty = ko.observable();
  
      self.bidVolume = ko.observable();
      self.bid = ko.observable();
      self.offer = ko.observable();
      self.offerVolume = ko.observable();
  
  
  
      self.add = function (canadiancrude) {
          var payload = {
              Term: this.selectedTerm(), Product: this.selectedChoice(), Location: this.selectedLocation(), Pipeline: this.selectedPipeline(),
              BidCP: this.selectedBidCounterParty(), BidVolume: this.bidVolume(), Index: this.selectedIndex(), Bid: this.bid(), Offer: this.offer(),
              OfferVolume: this.offerVolume(), OfferCP: this.selectedOfferCounterParty()//, Locked: "0", Sequence: "", TermID: "0"
          };
          $.ajax({
              url: '/odata/Canadiancrudes',
              type: 'POST',
              //  data: ko.toJSON(payload),
              data: JSON.stringify(payload),
              contentType: 'application/json',
              dataType: 'json'
          });
      }
  </code></pre>
  
  <p>May I know where I am making a mistake in that?</p>