如何在一个视图中将表TD值从MVC3中的另一个视图中获取 [英] How to get Table TD value from one View to another different View in MVC3

查看:77
本文介绍了如何在一个视图中将表TD值从MVC3中的另一个视图中获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii to all,

我在MVC3 employee1视图和EmployeeEdit视图中创建了两个视图,我在empoloyee1视图中创建了一个表,其中包含Empid,Ename,Task等字段,名为Edit(链接字段)当员工点击编辑链接字段时,我们需要重定向到可编辑视图,在此可编辑视图中我需要访问可编辑视图中的各个行Empid,请告诉我如何访问特定的TD值从一个视图到另一个视图





谢谢

Ramu

Hii to all,
I have created two Views in MVC3 employee1 view and EmployeeEdit view, i have created a table in empoloyee1 view with fields like Empid,Ename,Task and more Field called Edit(Link Field)when ever employee clicks on Edit Link field we need to redirect to Editable view,in this Editable View i need the access respective rows Empid in Editable View,please tell me how can i access particular TD value From one View to different View


Thanks
Ramu

推荐答案

例如下面是员工列表视图

For example below are the Employee Listing View
@model IEnumerable<mvcapplication1.models.employeetwo>

@{
    ViewBag.Title = "_employeeTwo";
}

<h2>_employeeTwo</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
//The  parameters of ActionLink are LinkText,ActionResult Name and parameter(your edited id) pass to the Edit ActionResult.Please make sure that the id we pass inside the ActionLink is same as the id in Edit Action Result
            @Html.ActionLink("Edit", "Edit", new { id=item.Id })
          
        </td>
    </tr>
}

</table>





当您单击编辑链接按钮重定向到同一控制器中的编辑ActionResult时。 />



When you click the edit link button redirect to the Edit ActionResult within the Same controller.

[HttpGet]
public ActionResult Edit(int id)
{
//do the business logic for getData by id and return the model
return View(model);
}





希望这有帮助



Hope this helps


这篇关于如何在一个视图中将表TD值从MVC3中的另一个视图中获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆