これを再確認したところ、配置が間違っていたことがわかりましたが、データがボックスに追加されず、「空の」テキストでさえなく、ページに空白が表示されるというエラーが発生しましたが表示されていますが、デバッグ中に追加部分を叩いたときに表示されているため、データが見つかっています
public class BrandDropDownList : DropDownList
{
protected override void OnLoad(EventArgs e)
{
BrandListRetrieve();
base.OnLoad(e);
}
public void BrandListRetrieve()
{
var factory = new BrandFactory();
var customBool1State = factory.ByCustomBoolean1(true, CoreHttpModule.Session);
if (customBool1State != null)
{
var brandDropDown = CoreHttpModule.Session.CreateCriteria(typeof(Brand)).List<Brand>();
DropDownList brandDropDownList = new DropDownList();
foreach (Brand brand in brandDropDown)
{
brandDropDownList.Items.Add(brand.Name);
}
if (brandDropDownList.Items.Count < 0)
{
brandDropDownList.Items.Insert(0, new ListItem("Hello World", "Hello World"));
}
brandDropDownList.DataBind();
}
}
}
ASP.NET
<needlesports:BrandDropDownList runat="server" Visible="true" />