无法从下拉列表中检索guid

时间:2016-06-08 13:40:11

标签: c# asp.net webforms

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

类中的数据很好但是当我将guid保存回数据库以供参考时我得到错误:" guid不是识别的格式"。

当我看到值attribtute时它是空的

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

    /// <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

1 个答案:

答案 0 :(得分:0)

将整个代码放在!IsPostBack内的Page_Load上。您正在重新初始化_fhsPersonal。您还在btn_Click事件中使用相同名称的变量。改变它。