代码之家  ›  专栏  ›  技术社区  ›  scrot

C#-这段代码无法正常运行的原因是什么?

c#
  •  0
  • scrot  · 技术社区  · 17 年前

    出于某种原因,第1节有效,但第2节无效。当以相反的顺序运行时(2在1之前),第1节(附属关系)根本不会运行。所有的数据都是一样的。

    //Section 1
    
                UserService.DsUserAttributes dsAffiliation = us_service.GetUserAttributeDropDown(systemId, "Affiliation");
                Affiliation.DataSource = dsAffiliation.tblDropDownValues;
                Affiliation.DataTextField = "AttrValue";
                Affiliation.DataValueField = "Id";
                Affiliation.DataBind();                
    
    //Section 2                 
                UserService.DsUserAttributes dsCountry = us_service.GetUserAttributeDropDown(systemId, "Country");
                Country.DataSource = dsCountry.tblDropDownValues;
                Country.DataTextField = "AttrValue";
                Country.DataValueField = "Id";
                Country.DataBind();
    
    2 回复  |  直到 17 年前
        1
  •  2
  •   bdukes Jon Skeet    17 年前

    看起来肯定是 us_service.GetUserAttributeDropDown(systemId, "Country") dsCountry.tblDropDownValues 正在抛出异常。您需要使用调试器来了解是哪个以及为什么。

        2
  •  0
  •   Joachim Kerschbaumer    17 年前

    我想这在很大程度上取决于“国家”和“附属关系”对象。…任何事情都有可能发生。没有任何例外或类似情况,很难远程调试这些东西^^