我正在尝试获取用户和value (userD)
的下拉列表,但在json中返回UserID
值时遇到问题,而不是真正的user id value
我明白了
<option value="00000000-0000-0000-0000-000000000000">Test User1</option>
<option value="00000000-0000-0000-0000-000000000000">Test User2</option>
这是我的存储过程
USE [DojoDB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[rpGetUsers]
AS
BEGIN
SELECT [UserID] AS ID,
[UserFirstname] ,[UserSurname]
FROM [DojoDB].[dbo].[System_User]
END
这是我的班级
public class rpusers
{
public Guid UserID { get; set; }
public string UserFirstname { get; set; }
public string UserSurname { get; set; }
public string FullName {
get { return UserFirstname + " " + UserSurname; }
}
public int InstanceID { get; set; }
public int IsDeleted { get; set; }
public List<rpusers> rpusersList { get; set; }
public List<rpusersRecord> rpusersRecordList { get; set; }
}
HTML
@Html.DropDownListFor(m => m.FullName, new SelectList(Model.rpusersList, "UserID", "FullName"), new
控制器
public ActionResult rpusersChart()
{
rpusers objrpusers = new rpusers();
rpusersAction objRusersAction = new rpusersAction();
try
{
objrpusers.rpusersList = objRusersAction.GetrpusersDetails();
return View("~/Views/rpusers/rpusersChart.cshtml", objrpusers);
}
catch (Exception ex)
{
throw;
}
}
答案 0 :(得分:0)
我认为Guid是空白的,因为你的存储过程与属性被篡改的模型不匹配&#34; ID&#34;在存储过程中:
SELECT [UserID] AS ID,
和&#34; UserID&#34;在模型中:
public Guid UserID
因为程序没有返回&#34; UserID&#34;列UserID将作为默认Guid值(00000000-0000-0000-0000-000000000000
)。