0

How would you pass data code to angularjs variable. its working fine when the page loads. But when I click the button, for filter data. The server side does not load data.

$scope.studentinformation = <%= studentattendancejson %>

 protected void btnSearch_Click1(object sender, EventArgs e)
        {
string Query = "Select * from tblstudent WHERE student_name = 'Adeel'";
 var getstudentattendance = DbAccess.GetResult(Query);

      studentattendancejson = JsonConvert.SerializeObject(getstudentattendance, Formatting.Indented);
}

//Angularjs variable

<script type="text/javascript">
            var app = angular.module('myApp', []);
            app.controller('myCtrl', ['$scope', '$filter', function ($scope, $filter) {
                $scope.currentPage = 0;
                $scope.pageSize = 100;
                $scope.data = [];
                $scope.q = '';

                $scope.studentinformation = <%= studentattendancejson %>
                $scope.getData = function () {


                    return $filter('filter')($scope.studentinformation, $scope.q)

                }
                $scope.numberOfPages = function () {
                    return Math.ceil($scope.getData().length / $scope.pageSize);
                }


            }]);

            app.filter('startFrom', function () {
                return function (input, start) {
                    start = +start; //parse to int
                    return input.slice(start);
                }
            });

        </script>

 <tr ng-repeat="info in studentinformation| filter:q | startFrom:currentPage*pageSize | limitTo:pageSize">
                                                    <td>{{info.student_name}}</td>
                                                    <td>{{info.father_name}}</td>
                                                    <td>{{info.class_name}}</td>
                                                    <td>{{info.attendancedate | date:'dd-MM-yyyy'}}</td>
                                                    <td ng-if="info.attendanceType == 'Present'"> <button type="button" class="btn btn-success btn-circle"><i class="fa fa-check"></i></td>
                                                     <td ng-if="info.attendanceType == 'Absent'"> <button type="button" class="btn btn-danger btn-circle"><i class="fa fa-times"></i></td>
                                                     <td ng-if="info.attendanceType == 'Leave'"> <button type="button" class="btn btn-warning btn-circle"><i class="fa fa-list"></i></td>


                                                </tr>

Page load its working fine Page load its working fine

Button clicked button event its not show data, below are result enter image description here

3
  • Razor c# is only ran when the request is made so the studentattendancejson will not be changed. I think you need to look into using ajax for getting information from the server. Commented Mar 12, 2017 at 0:47
  • What is the error message in console Commented Mar 12, 2017 at 1:42
  • Possible duplicate of how to reload ng-repeat when i clicked button asp.net (angularjs) Commented Mar 14, 2017 at 13:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.