You must Sign In to post a response.
  • Category: .NET

    Mvc simple insertion for brginers practice coding list

    @using Entities;
    @model DTO.EmpModel
    @{
    Layout = null;
    }

    <!DOCTYPE html>

    <html>
    <head>
    <meta name="viewport" content="width=device-width" />
    <title>EmpCategory</title>
    </head>
    <body>
    @using (Html.BeginForm("EmpCategory", "Employee", FormMethod.Post))
    {
    <div>
    <table>

    <tr>
    <td><b>Employee Category:</b></td>
    <td>
    @Html.TextAreaFor(model => model.EmpCategory)

    </td>
    </tr>
    <tr>
    <td><b>Employee Name:</b></td>
    <td>
    @Html.TextAreaFor(model => model.Empname)

    </td>
    </tr>
    <tr>
    <td><b>Prefix :</b></td>
    <td>
    @Html.TextAreaFor(model => model.Prefix)
    </td>

    </tr>
    <tr>
    <td></td>
    <td>
    <input type="submit" value="Submit" /></td>
    </tr>
    </table>
    </div>
    }

    @using (Html.BeginForm("EmpCategory", "Employee", FormMethod.Get))
    {
    <div>
    <table>
    @foreach (var item in ViewData["EmpDetail"] as IEnumerable<Employee>)
    {
    <tr>
    <td>@item.EmpCategory</td>
    </tr>
    }
    </table>
    </div>
    }
    </body>
    </html>
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using DTO;
    using Entities;
    using AutoMapper;
    namespace WebApp.Controllers
    {
    public class EmployeeController : Controller
    {
    LocTestEntities3 objContext = new LocTestEntities3();

    public ActionResult Index()
    {
    return View();
    }
    [HttpGet]
    public ActionResult EmpCategory()
    {
    List<Employee> emp = objContext.Employees.ToList();
    ViewData["EmpDetail"] = emp;
    return View();
    }

    [HttpPost]
    public ActionResult EmpCategory(EmpModel Emp)
    {

    if (ModelState.IsValid)
    {
    Mapper.CreateMap<EmpModel, Employee>().ForMember(t => t.EmpId, opt => opt.Ignore());
    var empdetails = Mapper.Map<EmpModel, Employee>(Emp);
    objContext.Employees.Add(empdetails);
    objContext.SaveChanges();
    return RedirectToAction("Index");
    }

    return View();
    }

    }
    }
  • #766025
    What is the issue ? or do you want to share some code with us ? if it is then you can write an article in article section, it will be very useful to all members, if your article is having good quality then you can be applicable for revenue share and cash credit
    so hurry, and click below link
    http://www.dotnetspider.com/resources/PostResource.aspx?CategoryId=

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #766027
    Hi Prakash,

    If you have any queries related to code then you can post here in forum.If you want share your code for knowledge sharing then write an article inside article section.

  • #766034
    Hi,

    Please post your code snippets in article section that will reach more people.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #766037
    Hi

    What is your issue can you share your issue with snapshots.

    Can you attached your project zip format then reply people easily fixed in ur issue.

    Name : Dotnet Developer-2015
    Email Id : kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #766046
    Hai Prakash,
    This is not the place to share anything. The Forum section is exclusively for the question and answers. If the members are getting some issues in their development, they can post their code or ask the suggestions to get their issues resolved.
    So do not post any such code in the forum section to share. If you have any double or you need to ask questions related to the Microsoft technologies, you can post them here.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #766048
    Hello Prakash,

    I hope you are trying to post the article in the forum section. There is separate section for posting the articles.
    If you post the code in forum section it will not visible in resource section. And also you will not get the benifit as you expect.

    Following is the link for post the articles
    http://www.dotnetspider.com/resources/

    And also while posting the resource you have to describe the code. You have to give some explanation and derivation of your code. If you have any doubts or you have any issues in your code you can post here and also tell the issue clearly so that we can help you

    By Nathan
    Direction is important than speed


  • Sign In to post your comments