如何传递单个字段的多个值以编辑Mvc页面 [英] How Do I Pass Multiple Values Of A Single Field To Edit Page Of Mvc

查看:142
本文介绍了如何传递单个字段的多个值以编辑Mvc页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是MVC的新手.我已经创建了员工请假申请的索引页面.单名员工有多种请假类型,如CL,SL,CML等.索引页面包含Empid(外键),emp名称,不同的休假类型(Foreign Key)及其余额和SNO(即主键).当我单击以编辑记录时,应使用主键将其重定向到编辑页面,但我想传递多个值(即不同的主键).所以,我被困在这里.请帮助他解决我的问题.

I''m new in MVC. I have created an index page of leave application of employees. Single employee has multiple leave types like CL,SL,CML,etc. The index page contains empid (Foreign Key), emp name,different leave types(Foreign Key) with their balance and SNO(i.e the primary key ). when I click to edit the record it should redirect to edit page with the primary key but i want to pass multiple values(i.e different primary keys). So, I''m stuck here. Please help him to resolve my problem.

推荐答案

查看

View

@{  
    RouteValueDictionary ids = new RouteValueDictionary();
    ids.Add("id[0]", 1);
    ids.Add("id[1]", 2);
    ids.Add("id[2]", 3);
}

@Html.ActionLink("Click", "MyAction", "Home", ids, null)



控制器



Controller

public ActionResult MyAction(int[] id)
{
    foreach(int x in id)
    {
        System.Diagnostics.Debug.WriteLine(x);
    }

    return View();
}


这篇关于如何传递单个字段的多个值以编辑Mvc页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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