ChannelCollection based on Custom Property
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
ChannelCollection based on Custom Property

 
Post new topic   Reply to topic    Windows Server Forum Index -> CMS Server
Author Message
Lta
Guest





Posted: Thu Oct 27, 2005 12:51 pm    Post subject: ChannelCollection based on Custom Property Reply with 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
Mei Ying [MVP]
Guest





Posted: Thu Oct 27, 2005 12:51 pm    Post subject: RE: ChannelCollection based on Custom Property Reply with 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:

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 Reply with quote

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 Reply with quote

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
 
Post new topic   Reply to topic    Windows Server Forum Index -> CMS Server All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB