Posts

How to bind Static Data to DropDownList in Asp.Net MVC with c#

@model MySample.Models.EmployeeDepartment @{ ViewData.Name="GSV" } < H1>GSV</H1> @using(Html.BeginForm()) { @Html.AntiForeignKeyToken() @Html.ValidationSummary() < div> @Html.Label("Select Employee",new {@class="from-contol"}) < div class="form-group"> @Html.DropDownListFor  (m=>m.EmployeeId,new List<SelectListItem>(){ new SelectListItem(){Text="One",Value=1}, new SelectListItem(){Text="Two",Value=2}, new SelectListItem(){Text="Three",Value=3}, new SelectListItem(){Text="Four",Value=4}, },new {@class="form-control"}) < /div> < /div> }

How to Bind Drodown data in MVC Cshtml page in c#

First u consider Employee and Department Tables DepartmentContext : -------------------- Employee  Department Employee  ------------------ Id name departmentId   Foreign key From Department table Department: -------------------- id name View Model: EmployeeDepartment ------------------------ Id name EmployeeId EmployeeNames In Controller code: --------------------------------- Public ActionResult GSVActoionMethod() { DepartmentContext db=new DepartmentContext (); var employeeDepartments=db.Department.Select(a=> new EmployeeDepartment(){ Id = a.id, name=a.name, EmployeeNames=db.Employees.Where(m=>m.departmentId   == a.id).ToList() }) return View(employeeDepartments); } In ViewPage : GSVActoionMethod.cshtml ------------------------------------------------------ @model MySample.Models.EmployeeDepartment @{ ViewData.Name="GSV" } <H1>GSV</H1> @using(Html.BeginForm()) { @Html.AntiForeignK...

Web Api Using AngularJS

using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Data.Entity.Infrastructure; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; using System.Web.Http.Description; using AngularJSSample.Models; namespace AngularJSSample.Controllers {     [RoutePrefix("api/employee")]     public class EmployeesController : ApiController     {         private EmployeeEntities db = new EmployeeEntities();         // GET: api/Employees         [HttpGet]         [AllowAnonymous]         [Route("getemployee")]         public IQueryable<Employee> GetEmployees()         {             return db.Employees;         }         // GET: api/Employees/5   ...

How to calculate Round calculations Using C#

Here can u take monthly calculation to Round ur values u will get the Values in Result double  sample= ((( double )(Field1).(Field2)) / 12.0);                                  string [] str = sample.ToString().Split( '.' );                                  int  i = str.Count();                                  double  values = 0;               ...

Angular Js Post method using MVC

Image
Angular Js Post call Implementation: < !DOCTYPE html > < html > < head > < title ></ title > < meta charset ="utf-8" /> < link href ="Content/bootstrap.min.css" rel ="stylesheet" /> < script src ="Scripts/angular.min.js"></ script > < script src ="Scripts/bootstrap.min.js"></ script > </ head > < body ng-app =" myapp "> < form id ="form1" ng-controller =" mycontroller " ng-submit =" submit () "> <!--<div ng-controller="mycontroller">--> < div style =" padding : 50px ; "> < h1 style =" text-align : center ; border : burlywood ; background : azure ; "> Employee </ h1 > < div class ="row"> < div class ="col-m...