0

I have a mvc razor view, this view contains a couple records.Now how can i get record inside jquery dialog for update.I don't get record according by "Route ID" because it is 5 and no data that ID 5.Should i use it for ajax or can i solve this issue not use ajax?

Page details is follow.

EmployeeDetail.cshtml

URL : EmployeeDetail/5

@model EmployeeCvBank.EmployeeRepository

Person : Irakli Zuradze

Deparment : IT / Software Developer

                                                           + Add new education
+------+--------------------------------+----------------+-------------------+
|  ID  |  Education                     |  Graduate      |  Actions          |
+------+--------------------------------+----------------+-------------------+
|  1   |  Batumi University Msc         |  1/7/2012      |  Edit / Delete    |
+------+--------------------------------+----------------+-------------------+
|  2   |  Tbilisi State University Ms   |  25/9/2010     |  Edit / Delete    |
+------+--------------------------------+----------------+-------------------+

Edit and Delete action for Education knowledges

public ActionResult EditEducation(PersonEducation model)
{
    ...
}

public ActionResult DeleteEducation(int id)
{
    ...
}

public class EmployeeRepository
{
    public Employee Employee {get;set;}
    public Education Education {get;set;}
}
1
  • What do you mean with record id 5?
    – Marthijn
    Commented Dec 16, 2013 at 9:10

1 Answer 1

0

If I'm not wrong you want to modify Educational detail of user having Id 5 ?

There is always a way around

Steps

  1. Create Hidden field, which will hold your education id on form submit.

    @Html.Hidden("EducationId")
    
  2. Add onclick event to 'Edit' link

    <a href="javascript:PopulateHiddenFieldsBeforeSubmit('@education.id')" >Edit</a>
    <script>
      function PopulateHiddenFieldsBeforeSubmit(educationId)
       {
         $("#EducationId").val(educationId);//prove hidden educationid field with selected value
         document.forms[0].submit();
       }
    

  3. Decorate Employee post action

    Public ActionResult EmployeeDetail(EmployeeRepository collection, int EducationId)
    {
      //Now you have desired educationid here
    }
    

Not the answer you're looking for? Browse other questions tagged or ask your own question.