gpt4 book ai didi

c# - 无法从下拉列表中检索 guid

转载 作者:太空宇宙 更新时间:2023-11-03 15:20:00 25 4
gpt4 key购买 nike

我正在尝试从填充的下拉列表中将 guid 保存到数据库。

类中的数据很好,但是当我将 guid 保存回数据库以供引用时,出现错误:“guid 不是可识别的格式”。

当我查看值属性时它是空的

我正在使用以下内容来标准化我的查找

    /// <summary>
/// Gets the days of week.
/// </summary>
/// <returns></returns>
public List<StandardLookup> GetStandardLookups(Guid lookkupCode)
{
List<StandardLookup> lookups = new List<StandardLookup>();

try
{
var q = from lookup in fhsNetEntities.fhsLookUps.Where(a => a.lookup_type == lookkupCode).OrderByDescending(o => o.colOrder)
orderby lookup.lookup_description
select new
{
LookLookupValue = lookup.lookup,
LookupDescription = lookup.lookup_Code.Trim(),
Order = lookup.colOrder
};

if (q != null)
{
Array.ForEach(q.ToArray(), l =>
{
lookups.Add(new StandardLookup(l.LookLookupValue, l.LookupDescription, l.Order));
});
}
}
catch (Exception ex)

{
string inner = string.Empty;
if (ex.InnerException != null)
{
inner = ex.InnerException.ToString();
}
logger.Error("Error in GetDaysOfWeek function aperturenetdal " + ex.ToString() + " " + inner);
return null;
}

return lookups;
}



rdSaluation.DataSource = rdSaluations;
rdSaluation.DataValueField = "LookupValue";
rdSaluation.DataTextField = "LookupDescription";
rdSaluation.DataBind();

但是当我到达我的保存事件并进行调试时,我收到以下错误

enter image description here

在这里你可以看到它错误地抓取了名称值。

enter image description here

最佳答案

将整个代码放在 !IsPostBack 中的 Page_Load 上。否则,您正在重新初始化您的 _fhsPersonal。此外,您还在 btn_Click 事件中使用了同名变量。也改变它。

关于c# - 无法从下拉列表中检索 guid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37704190/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com