Click here to Skip to main content
15,920,438 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: what is difference betwee App_LocalResources and App_GlobalResources Pin
John C Rayan18-May-16 1:25
professionalJohn C Rayan18-May-16 1:25 
Questionrendom image upload Pin
Member 1181823013-May-16 21:46
Member 1181823013-May-16 21:46 
AnswerRe: rendom image upload Pin
ZurdoDev16-May-16 3:07
professionalZurdoDev16-May-16 3:07 
Questionrename image upload Pin
Member 1181823013-May-16 21:03
Member 1181823013-May-16 21:03 
QuestionRe: rename image upload Pin
ZurdoDev16-May-16 3:07
professionalZurdoDev16-May-16 3:07 
QuestionApplication design for multiple databases Pin
Stephen Holdorf13-May-16 2:24
Stephen Holdorf13-May-16 2:24 
AnswerRe: Application design for multiple databases Pin
Gerry Schmitz13-May-16 4:16
mveGerry Schmitz13-May-16 4:16 
AnswerRe: Application design for multiple databases Pin
Stephen Holdorf13-May-16 9:24
Stephen Holdorf13-May-16 9:24 
GeneralRe: Application design for multiple databases Pin
Stephen Holdorf14-May-16 10:26
Stephen Holdorf14-May-16 10:26 
GeneralRe: Application design for multiple databases Pin
Nathan Minier15-May-16 3:13
professionalNathan Minier15-May-16 3:13 
GeneralRe: Application design for multiple databases Pin
Stephen Holdorf15-May-16 9:53
Stephen Holdorf15-May-16 9:53 
GeneralRe: Application design for multiple databases Pin
Nathan Minier16-May-16 1:28
professionalNathan Minier16-May-16 1:28 
GeneralRe: Application design for multiple databases Pin
Stephen Holdorf16-May-16 2:33
Stephen Holdorf16-May-16 2:33 
QuestionHow to use Datarelation to Create Menu in c# asp.net Pin
Ameer Dhotre12-May-16 21:02
Ameer Dhotre12-May-16 21:02 
QuestionRe: How to use Datarelation to Create Menu in c# asp.net Pin
ZurdoDev16-May-16 3:08
professionalZurdoDev16-May-16 3:08 
AnswerRe: How to use Datarelation to Create Menu in c# asp.net Pin
Ameer Dhotre23-May-16 1:41
Ameer Dhotre23-May-16 1:41 
GeneralRe: How to use Datarelation to Create Menu in c# asp.net Pin
ZurdoDev23-May-16 1:46
professionalZurdoDev23-May-16 1:46 
GeneralRe: How to use Datarelation to Create Menu in c# asp.net Pin
Ameer Dhotre26-May-16 0:48
Ameer Dhotre26-May-16 0:48 
QuestionQuery About getting difference between two dates in mvc4 Pin
Member 1251934112-May-16 2:52
Member 1251934112-May-16 2:52 
SuggestionRe: Query About getting difference between two dates in mvc4 Pin
Richard Deeming12-May-16 3:20
mveRichard Deeming12-May-16 3:20 
AnswerRe: Query About getting difference between two dates in mvc4 Pin
John C Rayan13-May-16 1:22
professionalJohn C Rayan13-May-16 1:22 
QuestionVisual Studio Community 2015 and Metro-UI-CSS Pin
xiecsuk10-May-16 3:26
xiecsuk10-May-16 3:26 
AnswerRe: Visual Studio Community 2015 and Metro-UI-CSS Pin
Richard Deeming10-May-16 6:34
mveRichard Deeming10-May-16 6:34 
GeneralRe: Visual Studio Community 2015 and Metro-UI-CSS Pin
xiecsuk10-May-16 6:46
xiecsuk10-May-16 6:46 
Questionhi experts..i'm using dropdownlist statically for gender field its not show me proper data when im update Pin
sunil39-May-16 19:25
sunil39-May-16 19:25 
i'm using dropdownlist statically for gender field its not showing me proper data when im trying to update pls help..
Database doesn't contain any special Gender DB table..

Controller code for Edit:

public ActionResult Edit(int id = 0)
{
EmployeeCrud emp = new EmployeeCrud();
var empval = emp.FindById(id);
var empentity = new EmployeeEntity();
if (empval != null)
{
empentity.EmpID = empval.EmpID;
empentity.FirstName = empval.FirstName;
empentity.LastName = empval.LastName;
empentity.ContactNo = empval.ContactNo;
empentity.EmailID = empval.EmailID;
empentity.Address = empval.Address;
empentity.Dob = empval.dob;
empentity.Gender = empval.gender;
empentity.DeptName = empval.DeptName;
empentity.DeptID = empval.DeptID;
empentity.Desination = empval.desination;
empentity.Joining = empval.joining;
empentity.Salary = empval.salary;
    }
     ViewBag.DeptID = new SelectList(db.Depts, "DeptID", "DeptName", empentity.DeptID);
    return View(empentity);
}

//
// POST: /Employee/Edit/5

[HttpPost]
public ActionResult Edit(EmployeeEntity employee)
{
    if (ModelState.IsValid)
    {
        EmployeeCrud emp = new EmployeeCrud();
        var empval = emp.UpdateEmp(employee.EmpID,employee.FirstName,employee.LastName,employee.ContactNo,employee.EmailID,employee.Address,employee.Dob,employee.Gender,employee.DeptID,employee.Desination,employee.Joining,employee.Salary);

        db.SaveChanges();
        return RedirectToAction("Index");
    }
    ViewBag.DeptID = new SelectList(db.Depts, "DeptID", "DeptName", employee.DeptID);
    return View(employee);
}

Create View Code:
@model MvcEmpCrud3.Models.EmployeeEntity

@{
ViewBag.Title = "Create";
}

Create


@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
    <legend>Employee</legend>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.FirstName)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.FirstName, new { placeholder = "Enter First Name here"})
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.FirstName)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.LastName)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.LastName, new { placeholder = "Enter Last Name here"})
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.LastName)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.ContactNo)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.ContactNo, new { placeholder = "Enter Contact No here"})
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.ContactNo)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.EmailID)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.EmailID, new { placeholder = "Enter EmailId here" } )
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.EmailID)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Address)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.TextAreaFor(model => model.Address, new { style = "width: 300px; height: 70px;", placeholder = "Enter title here" })
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Address)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Dob)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.Dob)
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Dob)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Gender)
    </div>
    <div class="editor-field">
    <a href="http://www.codeproject.com/Members/html">@Html</a>.DropDownList("Gender", new List&lt;SelectListItem>{
    new SelectListItem{ Text="Male", Value="Male"},
    new SelectListItem{ Text="Female", Value="Female"}
    },"Select Gender")
     <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Gender)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.DeptID, "Dept")
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.DropDownList("DeptID",@ViewBag.DeptID as SelectList,"Select Department")
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.DeptID)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Desination)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.Desination, new { <a href="http://www.codeproject.com/Members/placeholder">@placeholder</a> = "Enter Designation here"})
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Desination)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Joining)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.Joining)
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Joining)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Salary)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.Salary, new { <a href="http://www.codeproject.com/Members/placeholder">@placeholder</a> = "Enter Salary here"})
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Salary)
    </div>

    <p>
        &lt;input type="submit" value="Create" />
    </p>
</fieldset>

}
@Html.ActionLink("Back to List", "Index")

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<a href="http://www.codeproject.com/Members/scripts">@Scripts</a>.Render("~/bundles/jqueryui")
<a href="http://www.codeproject.com/Members/Styles">@Styles</a>.Render("~/Content/themes/base/css")

<"script type="text/javascript">
    $(document).ready(function () {
        $("#Dob").datepicker({
            changeMonth: true,
            changeYear: true,
            dateFormat: 'dd/mm/yy'            

        });
        $("#Joining").datepicker({
            changeMonth: true,
            changeYear: true,
            dateFormat: 'dd/mm/yy'

        });
    });
</script>

}

Edit View Code:

@model MvcEmpCrud3.Models.EmployeeEntity

@{
ViewBag.Title = "Edit";
}

Edit


@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
    <legend>Employee</legend>

        <a href="http://www.codeproject.com/Members/html">@Html</a>.HiddenFor(model => model.EmpID)

      <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.FirstName)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.FirstName)
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.FirstName)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.LastName)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.LastName)
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.LastName)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.ContactNo)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.ContactNo)
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.ContactNo)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.EmailID)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.EmailID)
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.EmailID)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Address)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.Address)
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Address)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Dob)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.Dob)
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Dob)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Gender)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.DropDownListFor(model => model.Gender, new List&lt;SelectListItem> {new SelectListItem{Text="Male",Value="Male"},new SelectListItem{Text="Female",Value="Female"} })
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Gender)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.DeptID, "Dept")
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.DropDownList("DeptID", String.Empty)
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.DeptID)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Desination)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.Desination)
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Desination)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Joining)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.TextBoxFor(model => model.Joining)
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Joining)
    </div>

    <div class="editor-label">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.LabelFor(model => model.Salary)
    </div>
    <div class="editor-field">
        <a href="http://www.codeproject.com/Members/html">@Html</a>.EditorFor(model => model.Salary)
        <a href="http://www.codeproject.com/Members/html">@Html</a>.ValidationMessageFor(model => model.Salary)
    </div>

    <p>
        &lt;input type="submit" value="Save" />
    </p>
</fieldset>

}
@Html.ActionLink("Back to List", "Index")

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
 <a href="http://www.codeproject.com/Members/scripts">@Scripts</a>.Render("~/bundles/jqueryui")
<a href="http://www.codeproject.com/Members/Styles">@Styles</a>.Render("~/Content/themes/base/css")

<"script type="text/javascript">
    $(document).ready(function () {
        $("#Dob").datepicker({
            changeMonth: true,
            changeYear: true,
            dateFormat: "dd-mm-yy"
        });
        $("#Joining").datepicker({
            changeMonth: true,
            changeYear: true,
            dateFormat: "dd-mm-yy"
        });
    });

</script>

}

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.