从ASP.Net MVC3中的DropDown读取数据 [英] Read The Data From DropDown in ASP.Net MVC3

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

问题描述

大家好,

我正在使用数据库优先方法进行ASP.net MVC 3(空类型而不是Internet类型)...

我需要的是

步骤1:
我只是使用下拉菜单显示了公司所在的各个位置.该列表来自组织"表,而位置"仅是此组织表中的一个字符串字段,


步骤2:
用户进行注册时,下拉列表将显示位置..现在,用户选择印度,则此值(位置名称)应存储在UserLogin表中...

现在如何从下拉列表中读取值,我希望您能理解我的问题,并在此先感谢

Hi all,

I am doing the ASP.net MVC 3 (Empty type and not the internet type) with the Database First approach...

What i need is

Step 1:
I just used the dropdown to display the various locations where the company is located. The list comes from the Organization table and Location is only one string field in this Oranization Table,


Step 2:
While the user is doing registration, the dropdown list will show the locations.. Now, user selects India, then this value (Location Name) should store in the UserLogin Table...

Now how to read the value from the dropdown and i hope you understand my question and thanks in advance

推荐答案

仔细阅读这些内容

http://stackoverflow.com/questions/7943980/在asp-net-mvc-3中获取来自下拉列表的选择值 [> http://stackoverflow.com/questions/862743/asp-net-mvc- get-dropdown-list-value [ ^ ]
Go through these

http://stackoverflow.com/questions/7943980/getting-selected-value-from-dropdownlist-in-asp-net-mvc-3[^]

http://stackoverflow.com/questions/862743/asp-net-mvc-get-dropdown-list-value[^]


请参阅以下内容:

http://stackoverflow.com/Problems/10550420/how-to-to-read-the-data-from-dropdown-in-asp-net-mvc-3 [ ^ ]

http://stackoverflow. com/questions/6308202/如何从mvc3中的数据库中获取数据在下拉列表中
Refer these:

http://stackoverflow.com/questions/10550420/how-to-read-the-data-from-dropdown-in-asp-net-mvc-3[^]

http://stackoverflow.com/questions/6308202/how-can-get-data-in-drop-down-list-from-data-base-in-mvc3


Sandeep

一次查看代码


//我的代码
公共无效addUser(User_Details_Class UDCObj)
{

//创建用于存储数据和添加数据的对象

WM_DB.User_Details UDObj =新的User_Details();

//配对
UDObj.UId = UDCObj.UId;
UDObj.UName = UDCObj.UName;
UDObj.UPassword = UDCObj.UPassword;
UDObj.ULocation =//您在此处编写代码以捕获从下拉列表中选择的数据


//这里很明显,我正在像id,password和
一样逐一分配值 //在这里,我无法读取下拉列表中的值.

//如果可以捕获,那么可以肯定的是,可以通过组合我的代码和您的代码将其添加到用户表中...

//我希望你能理解我的代码

//保存数据
dbcontext.User_Details.AddObject(UDObj);
dbcontext.SaveChanges();


}
Hi sandeep

see code here once


// My Code
public void addUser(User_Details_Class UDCObj)
{

// Creating Object to Store data and assingning Data

WM_DB.User_Details UDObj = new User_Details();

// Assinging
UDObj.UId = UDCObj.UId;
UDObj.UName = UDCObj.UName;
UDObj.UPassword = UDCObj.UPassword;
UDObj.ULocation = // you write your code here to catch the data which is selected from drop down


// Here it is clear that i am assigning values one by one like id,password and
// here i am failed to read the value form dropdown.

// If we catch then surely we can add it into user table by combing my code and your code...

// I hope u understand my code

//Saving Data
dbcontext.User_Details.AddObject(UDObj);
dbcontext.SaveChanges();


}


这篇关于从ASP.Net MVC3中的DropDown读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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