Click here to Skip to main content
15,887,930 members
Home / Discussions / C#
   

C#

 
GeneralRe: how do i insert data into a table Pin
Pete O'Hanlon27-Jul-15 0:35
mvePete O'Hanlon27-Jul-15 0:35 
GeneralRe: how do i insert data into a table Pin
jamesmc153527-Jul-15 1:03
jamesmc153527-Jul-15 1:03 
GeneralRe: how do i insert data into a table Pin
Pete O'Hanlon27-Jul-15 1:10
mvePete O'Hanlon27-Jul-15 1:10 
GeneralRe: how do i insert data into a table Pin
jamesmc153527-Jul-15 1:15
jamesmc153527-Jul-15 1:15 
GeneralRe: how do i insert data into a table Pin
Sascha Lefèvre27-Jul-15 2:28
professionalSascha Lefèvre27-Jul-15 2:28 
GeneralRe: how do i insert data into a table Pin
jamesmc153527-Jul-15 2:40
jamesmc153527-Jul-15 2:40 
AnswerRe: how do i insert data into a table Pin
Pete O'Hanlon27-Jul-15 0:24
mvePete O'Hanlon27-Jul-15 0:24 
QuestionDisplay data from SQL database to HTML page in table format using Angular JS Pin
iamcpmember27-Jul-15 0:01
professionaliamcpmember27-Jul-15 0:01 
Hi,

I want to fetch data from SQL database, and display the same on my HTML page in table format using Angular JS.

I am able to get the data in the scope variable, but it is not getting displayed in the HTML page.

Please check the code that I have written below, and help me fixing the issue.

Thanks in advance.

HTML code:
<!DOCTYPE html>

<html>

<head>

    <title>:: View Logs ::</title>

    <script src="Scripts/angular.js"></script>
    <script src="Scripts/angular.min.js"></script>

    <!--<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>-->

    <script src="Scripts/logsController.js"></script>
    <script src="Scripts/jquery-2.1.1.js"></script>
    <script src="Scripts/jquery-2.1.1.min.js"></script>

    <!--<script>
        ViewLogsApp = angular.module('ViewLogsApp', []);
        ViewLogsApp.controller('ViewLogsController', function ($scope, $http) {
            $http.get('data.json').success(function (response) {
                $scope.myData = response;
            });
        });
    </script>-->

</head>

<body>

    <div ng-app="ViewLogsApp">

        <div ng-controller="ViewLogsController">

            <table class="table table-striped">

                    <tr>
                        <th>Log ID</th>
                        <th>User Type</th>
                        <th>User Name</th>
                        <th>Email ID</th>
                        <th>Action Type</th>
                        <th>Section Name</th>
                        <th>Section Details</th>
                        <th>DateTime</th>
                        <th>User IP</th>
                    </tr>

                    <tr ng-repeat="item in logslist">
                        <td>{{item.LogID}}</td>
                        <td>{{item.UserType}}</td>
                        <td>{{item.UserName}}</td>
                        <td>{{item.EmailID}}</td>
                        <td>{{item.ActionType}}</td>
                        <td>{{item.SectionName}}</td>
                        <td>{{item.SectionDetails}}</td>
                        <td>{{item.DateTime}}</td>
                        <td>{{item.UserIP}}</td>
                    </tr>

            </table>

        </div>

    </div>

</body>

</html>





logsController.js code:
angular.module('ViewLogsApp', [])
  .controller('ViewLogsController', [
        '$scope', function ($scope) {

            $scope.logslist = [];

            $scope.load;

            $scope.load = function () {

                $.ajax({
                    type: 'GET',
                    contentType: 'application/json; charset=utf-8',
                    url: 'UserActivityLogs.aspx/getList',
                    success: function (data) {
                        $scope.logslist = data
                        $scope.$apply();
                    }
                });
            }
            $scope.load();

        }
  ]);





WebMethod code:
[System.Web.Services.WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public static List<UserActivityLogsList> getList()
{
    SqlConnection con = new SqlConnection();

    con.ConnectionString = _connstr;
    con.Open();

    var logs = new List<UserActivityLogsList>();

    string get = "select * from UserActivityLogs";
    //string get = "sp_employee";

    SqlCommand cmd = new SqlCommand(get, con);

    SqlDataReader dr = cmd.ExecuteReader();

    while (dr.Read())
    {
        UserActivityLogsList e = new UserActivityLogsList();

        e.LogID = Convert.ToInt32(dr[0]);
        e.UserType = Convert.ToString(dr[1]);
        e.UserName = Convert.ToString(dr[2]);
        e.EmailID = Convert.ToString(dr[3]);
        e.ActionType = Convert.ToString(dr[4]);
        e.SectionName = Convert.ToString(dr[4]);
        e.SectionDetails = Convert.ToString(dr[4]);
        e.DateTime = Convert.ToString(dr[4]);
        e.UserIP = Convert.ToString(dr[4]);

        logs.Add(e);

    }

    con.Close();

    return logs;

}

Clouds come floating into my life, no longer to carry rain or usher storm, but to add color to my sunset sky. ~Rabindranath Tagore

AnswerRe: Display data from SQL database to HTML page in table format using Angular JS Pin
Richard MacCutchan27-Jul-15 0:18
mveRichard MacCutchan27-Jul-15 0:18 
QuestionPicture Viewer. Pin
Member 1186549926-Jul-15 23:07
Member 1186549926-Jul-15 23:07 
AnswerRe: Picture Viewer. Pin
Pete O'Hanlon26-Jul-15 23:18
mvePete O'Hanlon26-Jul-15 23:18 
AnswerRe: Picture Viewer. Pin
Sebastiaan Lubbers29-Jul-15 0:32
professionalSebastiaan Lubbers29-Jul-15 0:32 
QuestionC# Read/Write PowerPoint.PageSetup.FirstSlideNumber Pin
Member 1185927326-Jul-15 14:31
Member 1185927326-Jul-15 14:31 
AnswerRe: C# Read/Write PowerPoint.PageSetup.FirstSlideNumber Pin
Richard Deeming27-Jul-15 2:02
mveRichard Deeming27-Jul-15 2:02 
QuestionRe: C# Read/Write PowerPoint.PageSetup.FirstSlideNumber Pin
Eddy Vluggen27-Jul-15 2:02
professionalEddy Vluggen27-Jul-15 2:02 
GeneralGridView - Update query Pin
Member 1186428526-Jul-15 8:45
Member 1186428526-Jul-15 8:45 
GeneralRe: GridView - Update query Pin
Wes Aday26-Jul-15 9:12
professionalWes Aday26-Jul-15 9:12 
GeneralRe: GridView - Update query Pin
Sascha Lefèvre26-Jul-15 9:49
professionalSascha Lefèvre26-Jul-15 9:49 
QuestionHow to copy and replace folder in desktop with C#/Winforms? Pin
George Tourtsinakis26-Jul-15 7:40
George Tourtsinakis26-Jul-15 7:40 
QuestionRe: How to copy and replace folder in desktop with C#/Winforms? Pin
Richard MacCutchan26-Jul-15 22:24
mveRichard MacCutchan26-Jul-15 22:24 
AnswerRe: How to copy and replace folder in desktop with C#/Winforms? Pin
George Tourtsinakis26-Jul-15 22:41
George Tourtsinakis26-Jul-15 22:41 
GeneralRe: How to copy and replace folder in desktop with C#/Winforms? Pin
Richard MacCutchan26-Jul-15 23:01
mveRichard MacCutchan26-Jul-15 23:01 
GeneralRe: How to copy and replace folder in desktop with C#/Winforms? Pin
George Tourtsinakis27-Jul-15 1:18
George Tourtsinakis27-Jul-15 1:18 
GeneralRe: How to copy and replace folder in desktop with C#/Winforms? Pin
Richard MacCutchan27-Jul-15 1:34
mveRichard MacCutchan27-Jul-15 1:34 
GeneralRe: How to copy and replace folder in desktop with C#/Winforms? Pin
George Tourtsinakis27-Jul-15 2:10
George Tourtsinakis27-Jul-15 2:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.