Execute SQL query in Controller using AngularJS in ASP.Net MVC

Last Reply one month ago By dharmendr

Posted one month ago


I have 2 tables in database like below


RId RName RNo Rquery

1 Invoice 233 select OrderName,OrderDate,RAI_Item,RAI_Quantity,RAI_Price,RAI_Total f from Orders5 o inner join Items6 i on o.OrderId=i.OrderId where OrderDate between

Display record on HTML Table based upon dynamic control values using AngularJS in ASP.Net MVC

In above code i have exceute query based on controls

assume in this code I don't have controls

if no controls present then execute simple query and or else controls query we have only simple query

just i need to execute this query and display records ongrid view

    Layout = null;
<!DOCTYPE html>
    <meta name="viewport" content="width=device-width" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.js"></script>
    <script type="text/javascript">
        var app = angular.module("MyApp", []);
        app.controller("MyControll", ['$scope', '$http', '$filter', function ($scope, $http, $filter) {
            function GetReportName() {
                $scope.reports = [];
                    method: 'Get',
                    url: '/Home/GetReportNames'
                }).success(function (data, status, headers, config) {
                    $scope.reports = data;
                }).error(function (data, status, headers, config) {
                    $scope.message = 'Unexpected Error';
                     $scope.Save = function () {
                var Id1 = $scope.items;
                var rId = $scope.RName;
                var details = {};
                var array = [];
                for (var i = 0; i < $scope.items.length; i++) {
                    var data = {};
                    data.Text = $scope.items[i].CName;
                    if ($scope.items[i].CType.toLowerCase() == 'dropdown') {
                        data.Value = $scope.items[i].FromTable;
                    } else if ($scope.items[i].CType.toLowerCase() == 'datepicker') {
                        data.Value = ConvertDate($scope.items[i].Date.toString());
                    } else if ($scope.items[i].CType.toLowerCase() == 'textbox') {
                        data.Value = $scope.items[i].ValueCName;
                    details.RId = rId;
                    details.details = array;
                    method: "Post",
                    url: "/Home/PopulateTable",
                    dataType: 'json',
                    headers: { "Content-Type": "application/json" },
                    data: '{values: ' + JSON.stringify(details) + '}'
                }).success(function (data) {

                    // Assign scope to bind gridview.
                }).error(function (err) {

Please try to modify in this code 


This question does not have replies that have been liked.