title: Why my data is not updating?
body: <p>I am trying to update ClientInfo table. But it is not updating and shows that Undefined. Those code below i have used in my controller for updating my database table data. Where is my problem i cannot find out? experts please help me..</p>
  
  <pre><code> [HttpPost]
          public JsonResult Update(ClientInfo clnt, int id)
          {
              if (ModelState.IsValid)
              {
                  ClientInfo c = db.Query&lt;ClientInfo&gt;("Select * from ClientInfo Where CId=@0", id).First&lt;ClientInfo&gt;();
                  c.CName = clnt.CName;
                  c.CCName = clnt.CCName;
                  c.Address = clnt.Address;
                  c.PhoneNo = clnt.PhoneNo;
                  c.Fax = clnt.Fax;
                  c.Email = clnt.Email;
                  c.Country = clnt.Country;
                  c.PostalCode = clnt.PostalCode;
                  c.Update();
                  return Json(c, JsonRequestBehavior.AllowGet);
              }
              else
                  return Json(new { msg = "Fail to Update Client Info." + id });
          }  
  </code></pre>
  
  <p>And Search Controller For searching Data</p>
  
  <pre><code>public JsonResult Search2(string id=null)
          {
              if (id != null)
              {
                  var sresult = db.Query&lt;ClientInfo&gt;("Where CId=" + id).ToList&lt;ClientInfo&gt;();
                  return Json(sresult, JsonRequestBehavior.AllowGet);
              }
              else
                  return null;
          }
  </code></pre>
  
  <p>And my ajax call from views For searching data by cid value..</p>
  
  <pre><code>@section scripts{
      @Scripts.Render("~/bundles/jqueryui")
      @Scripts.Render("~/bundles/jqueryval")
      @Styles.Render("~/Content/themes/base/css")
  
  &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $('#CId').blur(function () {
              var v = $('#CId').val();
              var url = "/Clients/Search2/" + v;
            //  alert("Test : " + url);
  
              $("#CName").val("");
              $("#CCName").val("");
              $("#PhoneNo").val("");
              $("#Fax").val("");
              $("#Email").val("");
              $("#Address").val("");
              $("#PostalCode").val("");
              $("#Country").val("");
  
              $.getJSON(url, null, function (data, status) {
                  $.each(data, function (index, C) {
                      $("#CName").val(C.CName);
                      $("#CCName").val(C.CCName);
                      $("#PhoneNo").val(C.PhoneNo);
                      $("#Fax").val(C.Fax);
                      $("#Email").val(C.Email);
                      $("#Address").val(C.Address);
                      $("#PostalCode").val(C.PostalCode);
                      $("#Country").val(C.Country);
                  });
              });
          });
  </code></pre>
  
  <p>For database update  i have used this function ...</p>
  
  <pre><code>        $('#btnUpdate').click(function () {
              var CId = $("#CId").val();
              var CName = $("#CName").val();
              var CCName = $("#CCName").val();
              var PhoneNo = $("#PhoneNo").val();
              var Fax = $("#Fax").val();
              var Email = $("#Email").val();
              var Address = $("#Address").val();
              var PostalCode = $("#PostalCode").val();
              var Country = $("#Country").val();
  
              var client1 = {
                  "CId": CId,
                  "CName": CName,
                  "CCName": CCName,
                  "PhoneNo": PhoneNo,
                  "Fax": Fax,
                  "Email": Email,
                  "Address": Address,
                  "PostalCode": PostalCode,
                  "Country": Country
              };
  
              var lk = "/Clients/Update/" + CId;
  
              //alert("Test : Update " + lk + "\n" + client1.Country);
              client = JSON.stringify(client1);
  
              $.ajax({
                  cashe: false,
                  async: false,
                  url: lk,
                  type: 'POST',
                  data: client,
                  dataType: "json",
                  success: function (data) {
                      alert(data.msg);
                  },
                  error: function (data) {
                      alert(data.msg);
                  }
              });
  
          });
      });
  
  &lt;/script&gt;
  }
  </code></pre>