title: Delete Button in Jquery table from SQL Server in mvc
body: <p>I am new in asp.net MVC and javascript. I tried to delete  record from SQL Database in jquery table for a particular row. I am adding different methods but it is failing. Please solve my  problem. Thanks for Advance..</p>
  
  <p><strong>This is my View Page</strong></p>
  
  <pre><code>&lt;script&gt;
  
      $("#txtcategory").change(function () {
          var tcity = $("#txt_city").val();
          var ta_add = $("#txta_address").val();
          var tb_add = $("#txtb_address").val();
          var t_dt = $("#txtdate").val();
          var cat = $("#txtcategory").val();
  
          $.get("get_data", { city: tcity, dt: t_dt, a_add: ta_add, b_add: tb_add, cate: cat }, function (data) {
              var row;
              $("#tbl_data").empty();
              row = "&lt;tr&gt;&lt;th&gt;Category&lt;/th&gt;&lt;th&gt;Vehicle Number&lt;/th&gt;&lt;th&gt;Date&lt;/th&gt;&lt;/tr&gt;";
              $.each(data, function (i, v1) {
  
                  row += "&lt;tr&gt;&lt;td&gt;" + v1.CATEGORY + "&lt;/td&gt;&lt;td&gt;" + v1.VEHICLE_NUMBER + "&lt;/td&gt;&lt;td&gt;" + v1.S_DATE + "&lt;/td&gt; "+ 
                  //"&lt; td &gt; " + " &lt; input type= 'button' id= '" + v1.ID + "' value= 'Delete' &gt; " + "&lt;/td &gt; "+
                      "&lt;td&gt;" + "&lt;button type='button' id='"+v1.ID+"' class='deleteContact btn btn btn- danger btn- xs'&gt;Delete&lt;/button&gt;"+"&lt;/td&gt;"+
                      "&lt;/tr&gt;"
              });
              $("#tbl_data").append(row);
  
          })
  
      });
  
      $(document).on("click", ".deleteContact", function () {
          $(this).closest("tr").remove(); // closest used to remove the respective 'tr' in which I have my controls   
      }); 
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>This is my Model Class</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  
  namespace fiverr_Map_Project.Models
  {
      public class Crud_Class
      {
          public int ID { get; set; }
          public string CITY { get; set; }
          public string A_LATLNG { get; set; }
          public string A_ADDRESS { get; set; }
          public string B_LATLNG { get; set; }
          public string B_ADDRESS { get; set; }
          public string CATEGORY { get; set; }
          public string VEHICLE_NUMBER { get; set; }
          public DateTime T_DATE { get; set; }
          public string S_DATE { get; set; }
      }
  }
  </code></pre>
  
  <p><strong>This is My DB Class</strong></p>
  
  <pre><code>public DataSet show_data(string city,DateTime dt,string a_add,string b_add,string cate)
          {
  
              SqlCommand com = new SqlCommand("select category,vehicle_number,CONVERT(VARCHAR(10), t_date, 101) as t_date from vehicle_entry where " +
  " city = '"+city+"' and t_date = '"+dt+"' and a_address = '"+a_add+"'" +
  " and b_address = '"+b_add+"' and category = '"+cate+"'", con);
              SqlDataAdapter da = new SqlDataAdapter(com);
              DataSet ds = new DataSet();
              da.Fill(ds);
              return ds;
          }
  </code></pre>
  
  <p><strong>Home Controller</strong></p>
  
  <pre><code> public JsonResult get_data(string city, DateTime dt, string a_add, string b_add, string cate)
          {
              DataSet ds = dblayer.show_data(city,dt,a_add,b_add,cate);
              List&lt;Crud_Class&gt; listreg = new List&lt;Crud_Class&gt;();
              foreach (DataRow dr in ds.Tables[0].Rows)
              {
                  listreg.Add(new Crud_Class
                  {
  
  
                      CATEGORY = dr["category"].ToString(),
                      VEHICLE_NUMBER = dr["vehicle_number"].ToString(),
                      S_DATE =dr["t_date"].ToString()
                  });
              }
              return Json(listreg, JsonRequestBehavior.AllowGet);
          }
  </code></pre>
  
  <p>Please help me. My Project have very short time. Thanks</p>