English 中文(简体)
C# 如何将数据清单从中获取到监控器 3
原标题:C# how to get list of data from view into controller in MVC 3

Please anyone tell me, how to get all list of modified data from view into controller in mvc3 at the time of page submit.

在我看来,有三栏:上栏、正栏、名称和支票箱,只想把检查数据输入控制器。

public class ResetLogin
{
    public string EmpID         { get; set; }
    public string EmpName       { get; set; }
    public bool   Checkbox      { get; set; }
}


public class ResetUserAll
{
   public List<ResetLogin> ResetUser { get; set; }  
}



           [Get]
           ResetUsersAll alluser = new ResetUsersAll();
            List<ResetUser> resetUser = new List<ResetUser>();  
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                ResetUser item = new ResetUser();
                item.EmpID = dr["emp_id"].ToString();
                item.EmpName = dr["emp_name"].ToString();
                resetUser.Add(item);
            }
            alluser.users = resetUser;
            return PartialView(alluser);


    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult ResetUserAll(ResetUserAll model) -- model showing null value

感谢

问题回答

控制器只得到浏览器提供的数据,因此,不会听说没有打箱子。

需要更明确地说明问题,以回答问题。

  1. mark all checkbox with the same name (i.e. "Checkbox") and set to each checkbox appropriate value of EmpID
  2. modify method [AcceptVerbs(HttpVerbs.Post)] public ActionResult ResetUserAll(string[] Checkbox) { } in Checkbox array you will have only checked values.

如果你只想获得这一数据,情况就是如此。

如果你想走路,请检查你的看法模式。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签