| Author |
Message |
Lta
Guest
|
Posted:
Thu Oct 27, 2005 12:51 pm Post subject:
ChannelCollection based on Custom Property |
|
|
Hello,
I am trying to retreive a channel clooection based on a custom property. I
have created an ArrayList of the channels I want and the ChannelCollection
but I am having problems returning the ArrayList as a Channel Collection.
Do you have any suggestions?
Thanks
public static ChannelCollection GetSubChannelsWithCustomProperty(Channel c,
string cp)
{
ChannelCollection cc = null;
ArrayList subCs = new ArrayList();
if (c!=null)
{
foreach (Channel sc in c.Channels)
{
CustomPropertyCollection cpc;
cpc = sc.CustomProperties;
if (cpc["nav"] != null)
{
string cpVal = cpc["nav"].Value.ToString().ToLower().Trim();
if (cpVal == cp)
{
subCs.Add(sc);
}
}
}
}
return (cc)subCh.ToArray(typeof(ChannelCollection));
} |
|
| Back to top |
|
 |
Mei Ying [MVP]
Guest
|
Posted:
Thu Oct 27, 2005 12:51 pm Post subject:
RE: ChannelCollection based on Custom Property |
|
|
Hi
The ChannelCollection class can't be cast as an ArrayList. Neither can you
add or remove items from the list programatically. You'll have to set the
return value to be an ArrayList or something else.
--
regards
Mei Ying
---
Blog: http://meiyinglim.blogspot.com
Book: http://www.packtpub.com/book/mcms
Contact: meiyinglim@hotmail.com
---
"Lta" wrote:
| Quote: | Hello,
I am trying to retreive a channel clooection based on a custom property. I
have created an ArrayList of the channels I want and the ChannelCollection
but I am having problems returning the ArrayList as a Channel Collection.
Do you have any suggestions?
Thanks
public static ChannelCollection GetSubChannelsWithCustomProperty(Channel c,
string cp)
{
ChannelCollection cc = null;
ArrayList subCs = new ArrayList();
if (c!=null)
{
foreach (Channel sc in c.Channels)
{
CustomPropertyCollection cpc;
cpc = sc.CustomProperties;
if (cpc["nav"] != null)
{
string cpVal = cpc["nav"].Value.ToString().ToLower().Trim();
if (cpVal == cp)
{
subCs.Add(sc);
}
}
}
}
return (cc)subCh.ToArray(typeof(ChannelCollection));
}
|
|
|
| Back to top |
|
 |
Lta
Guest
|
Posted:
Thu Oct 27, 2005 12:51 pm Post subject:
RE: ChannelCollection based on Custom Property |
|
|
Ok what about the other way round. Can an ArrayList be cast as a
ChannelCollection?
"Mei Ying [MVP]" wrote:
| Quote: | Hi
The ChannelCollection class can't be cast as an ArrayList. Neither can you
add or remove items from the list programatically. You'll have to set the
return value to be an ArrayList or something else.
--
regards
Mei Ying
---
Blog: http://meiyinglim.blogspot.com
Book: http://www.packtpub.com/book/mcms
Contact: meiyinglim@hotmail.com
---
"Lta" wrote:
Hello,
I am trying to retreive a channel clooection based on a custom property. I
have created an ArrayList of the channels I want and the ChannelCollection
but I am having problems returning the ArrayList as a Channel Collection.
Do you have any suggestions?
Thanks
public static ChannelCollection GetSubChannelsWithCustomProperty(Channel c,
string cp)
{
ChannelCollection cc = null;
ArrayList subCs = new ArrayList();
if (c!=null)
{
foreach (Channel sc in c.Channels)
{
CustomPropertyCollection cpc;
cpc = sc.CustomProperties;
if (cpc["nav"] != null)
{
string cpVal = cpc["nav"].Value.ToString().ToLower().Trim();
if (cpVal == cp)
{
subCs.Add(sc);
}
}
}
}
return (cc)subCh.ToArray(typeof(ChannelCollection));
}
|
|
|
| Back to top |
|
 |
Stefan [MSFT]
Guest
|
Posted:
Thu Oct 27, 2005 12:51 pm Post subject:
Re: ChannelCollection based on Custom Property |
|
|
Hi,
no this is not possible.
These two types are not compatible.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"Lta" <Lta@discussions.microsoft.com> wrote in message
news:68C00804-CF1D-494F-BFD5-C7081765025D@microsoft.com...
| Quote: | Ok what about the other way round. Can an ArrayList be cast as a
ChannelCollection?
"Mei Ying [MVP]" wrote:
Hi
The ChannelCollection class can't be cast as an ArrayList. Neither can
you
add or remove items from the list programatically. You'll have to set the
return value to be an ArrayList or something else.
--
regards
Mei Ying
---
Blog: http://meiyinglim.blogspot.com
Book: http://www.packtpub.com/book/mcms
Contact: meiyinglim@hotmail.com
---
"Lta" wrote:
Hello,
I am trying to retreive a channel clooection based on a custom
property. I
have created an ArrayList of the channels I want and the
ChannelCollection
but I am having problems returning the ArrayList as a Channel
Collection.
Do you have any suggestions?
Thanks
public static ChannelCollection
GetSubChannelsWithCustomProperty(Channel c,
string cp)
{
ChannelCollection cc = null;
ArrayList subCs = new ArrayList();
if (c!=null)
{
foreach (Channel sc in c.Channels)
{
CustomPropertyCollection cpc;
cpc = sc.CustomProperties;
if (cpc["nav"] != null)
{
string cpVal = cpc["nav"].Value.ToString().ToLower().Trim();
if (cpVal == cp)
{
subCs.Add(sc);
}
}
}
}
return (cc)subCh.ToArray(typeof(ChannelCollection));
}
|
|
|
| Back to top |
|
 |
|
|
|
|