如何在ASP.Net MVC 3下拉读取数据 [英] How to read the data from a dropdown in ASP.Net MVC 3

查看:128
本文介绍了如何在ASP.Net MVC 3下拉读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第1步:

我使用一个下拉显示公司的位置。名单来自于位置的表。

I'm using a dropdown to display company locations. The list comes from the Location table.

第二步:

当用户注册时,下拉列表将显示有问题的地点。

While the user is registering, the dropdown list will show the locations in question.

当用户选择印度,则此值(位置名称)应存储在用户登陆表

When the user selects India, then this value (Location Name) should store in the UserLogin Table.

如何读取从下拉在ASP.Net值MVC 3?

How can I read the value from the dropdown in ASP.Net MVC 3?

推荐答案

这取决于你正在传递的FormCollection然后只需你可以通过这个访问它的价值,你如何让你的表单值

It depends how you are getting values of your form if you are passing formcollection then simply you can access its value by this

public ActionResult MyAction (FormCollection form)
    {
        string value = form["DropDownListName"];
    }

或者你也可以通过

Or you can access it through

string value = Request.Form["DropDownListName"];

这篇关于如何在ASP.Net MVC 3下拉读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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