<prefix:mycontrol id=con property=AnArray> ???!??!?

S

Sally

Any ideas on how you handle this in the control? I am using C# if that matters.

Want to pass an array or even do id.AnArray=myarry;


-Sal
 
S

Scott Allen

Hi Sally:

This is generally done like:

<Custom:CollectionPropertyControl runat = "server">
<Custom:Employee Name = "Alice" Title = "Manager" />
<Custom:Employee Name = "Jerry" Title = "Programmer" />
<Custom:Employee Name = "Lynn" Title = "Architect" />
<Custom:Employee Name = "Mike" Title = "Tester" />
</Custom:CollectionPropertyControl>

Here we have an array of employees attached to the server control.

To pull this off you'll need to use the ParseChildrenAttribute
attribute. There is an example here:
http://msdn.microsoft.com/library/d...de/html/cpconparsechildrenattributesample.asp

HTH,
 
S

Sally

Thanks Scott, but what if the array is something determined at run
time (almost like a DataSource on a DataGrid)?
 
S

Scott Allen

Well, anything you can do in aspx you can also do programatically.

Take for instance the ListBox WebControl. You can add items in the
aspx file:

asp:ListBox id="ListBox1" runat="server" >
<asp:ListItem Value="1">item1s</asp:ListItem>
<asp:ListItem Value="2">item2</asp:ListItem>
</asp:ListBox>

Or you could add them programatically in the code behind:

ListBox1.Items.Add(new ListItem("item1", "1"));
ListBox1.Items.Add(new ListItem("item2", "2"));

or if you already have an array of ListItems declared, you can add
them all at once with the AddRange method.

If you already have an array or ArrayList of custom objects (with
public properties), you can use the use those objects as a DataSource.

HTH!
 
S

Sally

Thanks Scott, everything you say helps me
-Sal

Scott Allen said:
Well, anything you can do in aspx you can also do programatically.

Take for instance the ListBox WebControl. You can add items in the
aspx file:

asp:ListBox id="ListBox1" runat="server" >
<asp:ListItem Value="1">item1s</asp:ListItem>
<asp:ListItem Value="2">item2</asp:ListItem>
</asp:ListBox>

Or you could add them programatically in the code behind:

ListBox1.Items.Add(new ListItem("item1", "1"));
ListBox1.Items.Add(new ListItem("item2", "2"));

or if you already have an array of ListItems declared, you can add
them all at once with the AddRange method.

If you already have an array or ArrayList of custom objects (with
public properties), you can use the use those objects as a DataSource.

HTH!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top