开发者

Typesafe keyvaluepair enum

I have a public property on a custom control exposed like this:

public IList<KeyValuePair<ControlTypes, int>> ControlCollection {get;set;}

With ControlType as type enum like this:

public enum ControlTypes : int
{
DropDownList = 1,
TextBox = 2,
}
public ControlTypes ControlType {get;set;}

Basically I am trying to create a simple user control that will add a specified number of html controls based on the input of the ControlCollection property. Like this.

<x:CustomControl ID="abc" runat="server" ControlCollection="DropDownList,1,TextBox,5"/>

How would I ensure that the ControlCollection value开发者_如何学编程 is entered in a typesafe manner? Or is this even possible? Thanks.


I think you're looking for a Dictionary<TKey, TValue>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜