title: Binding Webgrid in MVC with Custom class in AngularJS
body: <p>Hello I am new to AngularJS, I want to bind the webgrid in then method of AngularJS</p>
  
  <pre><code>$scope.SaveDetails = function () {
                  debugger;
                  var UserID = '@Session["ID"]';
                  var ID ={ "Application_ID": $scope.Application.ID, "Release_ID": $scope.Release.ID, "Change_ID": $scope.Change.ID, "Environment_ID": $scope.Environment.ID, "Server_ID": $scope.Server.ID, "User_ID": UserID };
  
  
                  if ($scope.Application || $scope.Release || $scope.Change || $scope.Environment || $scope.Server)
                      $http({
                          method: 'POST',
                          url: '/Dashboard/SaveDetails/',
                          data: { Application_ID: $scope.Application.ID, Release_ID: $scope.Release.ID, Change_ID: $scope.Change.ID, Environment_ID: $scope.Environment.ID, Server_ID: $scope.Server.ID, User_ID: UserID },
                      }).then(function (resposne) {
                          debugger;
                          $scope.grid = resposne.data;
                          alert("Saved Successfully");
                      });
              }
  </code></pre>
  
  <p>I want to bind the webgrid before alert message. The data coming from the server is in the form of custom class</p>
  
  <pre><code>[HttpPost]
          public List&lt;LogData&gt; SaveDetails(SelectedID x)
          {
              application.SaveLogs(x.Application_ID, x.Release_ID, x.Change_ID, x.Environment_ID, x.Server_ID, x.User_ID);
              BLLogTable logs = new BLLogTable();
              List&lt;LogData&gt; data = new List&lt;LogData&gt;();
              data = logs.GetData(10, 10);
              return data;
          }
  </code></pre>
  
  <p>This is my Business layer. </p>
  
  <pre><code>public class BLLogTable
  {
      BRMContext db = new BRMContext();
  
      public List&lt;LogData&gt; GetData(int rowCount, int rowFrom)
      {
          var param1 = new SqlParameter();
          param1.ParameterName = "@Value1";
          param1.SqlDbType = SqlDbType.Int;
          param1.SqlValue = rowCount;
  
          var param2 = new SqlParameter();
          param2.ParameterName = "@Value2";
          param2.SqlDbType = SqlDbType.Int;
          param2.SqlValue = rowFrom;
  
          var query = db.LogDataContext.SqlQuery("BRM.spLogs @value1,@value2", param1, param2).ToList();
          List&lt;LogData&gt; x = new List&lt;LogData&gt;();
  
          foreach (var log in query)
              x.Add(log);
  
          return x;
      }
  
  }
  </code></pre>
  
  <p>I saw many answers using ajax calls. But I was unsure if they would work. I followed this answer <a href="https://stackoverflow.com/questions/13397837/mvc-3-razor-how-to-bind-new-model-to-webgrid-using-jquery-ajax">MVC 3 Razor- how to bind new model to webgrid using jQuery ajax</a></p>
  
  <p>I am able to get the data in the angularjs function <a href="https://i.stack.imgur.com/D4VyO.png." rel="nofollow noreferrer">The data is in custom class object LogsData</a>. How can I bind that data in mvc webgrid?</p>
  
  <p>Little Help Would be really great! Thanks in advance.</p>