Passing int list as a parameter to a web user control

前端 未结 8 1531
失恋的感觉
失恋的感觉 2020-12-14 04:15

I want to pass an int list (List) as a declarative property to a web user control like this:


         


        
8条回答
  •  抹茶落季
    2020-12-14 04:42

    The way I normally do this is to make the property wrap the ViewState collection. Your way looks better if it can be made to work, but this will get the job done:

    public IList ModuleIds
    {
       get
       {
           string moduleIds = Convert.ToString(ViewState["ModuleIds"])
    
           IList list = new Collection();
    
           foreach(string moduleId in moduleIds.split(","))
           {
              list.Add(Convert.ToInt32(moduleId));
           }
    
          return list;
       }
    }
    

提交回复
热议问题