ASPForums.Net RSS Feed additions to the content that appears on ASPForums.Net(c) 2019 All rights reserved.Execute SQL query in Controller using AngularJS in ASP.Net MVC<p>Hi <a class="username" rel="mahesh213"> mahesh213</a>,</p> <p>You need to check the parameter value.</p> <p>If there is value in parameter then control is present.</p> <p>So replace the place holder with value and execute the query else execute the database query.</p> <p>Check with the below code.</p> <p><strong><span style="text-decoration: underline;">C#</span></strong></p> <pre class="brush: csharp">[HttpPost] public JsonResult PopulateTable(Detail values) { TestEntities db = new TestEntities(); // Getting the query from Report1 table. string query = db.Report1.Where(x =&gt; x.RId == values.RId).Select(x =&gt; x.Rquery).FirstOrDefault(); // Check values if not null then control present and replace value. if (values.details != null) { for (int i = 0; i &lt; values.details.Count; i++) { string key = &#34;{&#34; + values.details[i].Text + &#34;}&#34;; string value = &#34;&#39;&#34; + values.details[i].Value + &#34;&#39;&#34;; // Replace the place holder with value. query = query.Replace(key, value); } } // Execute your final query and return json result and bind the gridview on success function. // Your code to return json. return Json(null, JsonRequestBehavior.AllowGet); }</pre> <p>&nbsp;</p>, 05 Sep 2019 04:04:53 GMT