开发者

Want to add new properies in ListItem Collection

开发者 https://www.devze.com 2023-01-03 14:52 出处:网络
I am working on to create a custom control inherited by CheckboxList control. We can add items from ListItem collection editior at the design time. In this ListItem Collection editor there are 4 prope

I am working on to create a custom control inherited by CheckboxList control. We can add items from ListItem collection editior at the design time. In this ListItem Collection editor there are 4 properties

1) Enabled

2) Selected

3) Text

4) value

I really need to add some new properties such as "ImageURL" and "IsClear". Do you h开发者_运维问答ave any ideas/methods or magic to add these properties.

I need Expert's opinion from StackOverFlow.com

Thanks


You can create a class that inherits from ListItem to add the properties. But inheriting from CheckBoxList would use the ListItem base type... You could try shadowing the Items collection to use your custom type, though I don't know that will work the same way... it depends where you need to use these new properties of the list item.

HTH.


Have you considered creating a User Control? You can define public members in the code behind that will then be accessible when you define the control on you aspx page.

Your aspx page would have something like this:

<%@ Register Assembly="MyCustomControls" Namespace="MyCustomControls" TagPrefix="cust" %>
...
<cust:MyCheckBoxList ID="cbl" runat="server" imageURL="http://blah.com/1.jpg" isClear="false />


The ListItem class has the Attributes property. Use it. You'll find there any additional attributes specified for asp:listitem in the mark-up that are not mapped to the properties.

0

精彩评论

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