ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Display alert message if nested GridView is Empty (No Record) using AngularJS in ASP.Net<p>Hi&nbsp;mahesh213,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">Database</span></strong></p> <p>For this example I have used of Northwind database that you can download using the link given below.</p> <p><a href="https://www.aspsnippets.com/Articles/Install-Microsoft-Northwind-and-Pubs-Sample-databases-in-SQL-Server-Management-Studio.aspx" target="_blank">Download Northwind Database</a></p> <p><strong><span style="text-decoration: underline;">Controller</span></strong></p> <pre class="brush: csharp">public class HomeController : Controller { // GET: /Home/ public ActionResult Index() { return View(); } [HttpGet] public JsonResult GeCustomerOrders() { NorthwindEntities db = new NorthwindEntities(); List&lt;CustomerModel&gt; CO = new List&lt;CustomerModel&gt;(); string[] customesids = new string[] { &#34;ALFKI&#34;, &#34;ANATR&#34;, &#34;FISSA&#34;, &#34;PARIS&#34; }; var cust = db.Customers.Where(x =&gt; customesids.Contains(x.CustomerID)).OrderBy(a =&gt; a.ContactName).ToList(); foreach (var i in cust) { List&lt;OrderDetail&gt; orders = db.Orders.Where(a =&gt; a.CustomerID.Equals(i.CustomerID)).Take(2) .OrderBy(a =&gt; a.OrderDate) .Select(x =&gt; new OrderDetail { OrderDate = x.OrderDate, ShipName = x.ShipName }).ToList(); CO.Add(new CustomerModel { Customers = new CustomerDetail { CustomerID = i.CustomerID, ContactName = i.ContactName, Address = i.Address }, Orders = orders }); } return new JsonResult { Data = CO, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } public class CustomerModel { public CustomerDetail Customers { get; set; } public List&lt;OrderDetail&gt; Orders { get; set; } } public class CustomerDetail { public string CustomerID { get; set; } public string ContactName { get; set; } public string Address { get; set; } } public class OrderDetail { public DateTime? OrderDate { get; set; } public string ShipName { get; set; } } }</pre> <p><strong><span style="text-decoration: underline;">View</span></strong></p> <pre class="brush: html">&lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head&gt; &lt;title&gt;Index&lt;/title&gt; &lt;link rel=&#34;stylesheet&#34; href=&#34;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css&#34; /&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdn.jsdelivr.net/npm/angular-utils-pagination@0.11.1/dirPagination.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; var app = angular.module(&#39;MyApp&#39;, [&#39;angularUtils.directives.dirPagination&#39;]); app.filter(&#34;dateFilter&#34;, function () { return function (item) { if (item != null) { return new Date(parseInt(item.substr(6))); } return &#34;&#34;; }; }); app.controller(&#39;MyController&#39;, function ($scope, $http, MyService) { GetAllEmployees(); //To Get All Employee Records function GetAllEmployees() { var getData = MyService.getemployee(); getData.then(function (emp) { $scope.Customers = emp.data; }, function (emp) { alert(&#34;Records gathering failed!&#34;); }); } $scope.Edit = function (CustomerID) { for (var i = 0; i &lt; $scope.Customers.length; i++) { if ($scope.Customers[i].Customers.CustomerID == CustomerID) { if ($scope.Customers[i].Orders.length &gt; 0) { alert(&#34;evrything is fine&#34;) } else { alert(&#34;valeus are not present in both grid views&#34;) } break; } } } }); app.service(&#34;MyService&#34;, function ($http) { //get All Employees this.getemployee = function () { return $http.get(&#34;/Home/GeCustomerOrders&#34;); }; }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div ng-app=&#34;MyApp&#34; ng-controller=&#34;MyController&#34;&gt; &lt;table class=&#34;table table-responsive&#34;&gt; &lt;thead&gt; &lt;tr class=&#34;success&#34;&gt; &lt;th&gt;&lt;/th&gt; &lt;th&gt;Id&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Address&lt;/th&gt; &lt;th&gt;Action&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody dir-paginate=&#34;customer in Customers|orderBy:sortKey:reverse|filter:search|itemsPerPage:10&#34;&gt; &lt;tr ng-class-even=&#34;&#39;even&#39;&#34; ng-class-odd=&#34;&#39;odd&#39;&#34;&gt; &lt;td&gt; &lt;button type=&#34;button&#34; ng-click=&#34;expanded = !expanded&#34; class=&#34;btn btn-default&#34;&gt; &lt;span ng-bind=&#34;expanded ? &#39;-&#39; : &#39;+&#39;&#34;&gt;&lt;/span&gt; &lt;/button&gt; &lt;/td&gt; &lt;td&gt;{{customer.Customers.CustomerID }}&lt;/td&gt; &lt;td&gt;{{customer.Customers.ContactName }}&lt;/td&gt; &lt;td&gt;{{customer.Customers.Address}}&lt;/td&gt; &lt;td ng-click=&#34;Edit(customer.Customers.CustomerID)&#34; class=&#34;btn btn-primary&#34;&gt;Edit&lt;/td&gt; &lt;/tr&gt; &lt;tr class=&#34;sub&#34; ng-show=&#34;expanded&#34;&gt; &lt;td&gt; &lt;/td&gt; &lt;td colspan=&#34;5&#34;&gt; &lt;table class=&#34;table table-responsive&#34;&gt; &lt;tr class=&#34;info&#34;&gt; &lt;th&gt;OrderDate&lt;/th&gt; &lt;th&gt;Ship Name&lt;/th&gt; &lt;/tr&gt; &lt;tr dir-paginate=&#34;order in customer.Orders|orderBy:sortKey:reverse|filter:search|itemsPerPage:10&#34; ng-class-even=&#34;&#39;even&#39;&#34; ng-class-odd=&#34;&#39;odd&#39;&#34;&gt; &lt;td&gt; &lt;input type=&#34;hidden&#34; ng-model=&#34;order.OrderID&#34; /&gt; {{order.OrderDate | dateFilter | date:&#34;dd-MM-yyyy&#34;}} &lt;/td&gt; &lt;td&gt;{{order.ShipName}}&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/BesNhy5.gif" alt="" width="390" height="544" /></span></strong></p>https://www.aspforums.net:443/Threads/753544/Display-alert-message-if-nested-GridView-is-Empty-No-Record-using-AngularJS-in-ASPNet/https://www.aspforums.net:443/Threads/753544/Display-alert-message-if-nested-GridView-is-Empty-No-Record-using-AngularJS-in-ASPNet/Wed, 24 Jul 2019 07:03:57 GMT