我有一个 ASP ,每次单击它时都会LinkButton
向它添加 ID 值。List<int>
我需要帮助的是如何在添加 20 个项目后向用户发布警报。用户不能添加超过 20 个,所以如果添加了第 21 个项目,我需要提醒他们。这是我当前的代码:
List<int> myList = new List<int>();
if(!String.IsNullOrEmpty(Session["mylist"] + String.Empty))
myList = (List<int>)Session["mylist"];
//Max 20 items in MyList
if (myList.Count < 20)
{
//Add item to list
}
else
{
//Alert to tell user that there are 20 items selected
}