Sort postings by custom property
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Microsoft Content Management Server > Sort postings by custom property




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Sort postings by custom property  
Mei Ying [MVP]


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-24-05 01:46 AM

Hi

Not directly. You could iterate through the list of=20
postings and store their custom property values in a=20
DataTable. You can then use a DataView to sort the list in=20
whatever order you like.

Something like this:
PostingCollection pc =3D c.Postings;

//put information about the postings in a table
DataTable dt =3D new DataTable();
=20
dt.Columns.Add("Name",System.Type.GetType
("System.String"));			=09
dt.Columns.Add("PromotionStartDate",System.Type.GetType
("System.DateTime"));
=09
DataRow newRow;
for (int i=3D0; i<pc.Count; i++)
{
//add a new row to the table for each posting in=20
the list
newRow =3D dt.NewRow();

//add the name
newRow["Name"] =3D pc[i].Name;

//add the date
newRow["PromotionStartDate"] =3D DateTime.Parse(pc
[i].CustomProperties["PromoDate"].Value);

//add the new row to the table
dt.Rows.Add(newRow);
}
=09
//bind the table to the datagrid
DataView dv =3D dt.DefaultView;
dv.Sort =3D "PromotionStartDate desc";
myDataGrid.DataSource =3D dv;
myDataGrid.DataBind();

regards
Mei Ying
---
Blog: http://meiyinglim.blogspot.com
Book: http://www.packtpub.com/book/mcms
Contact: meiyinglim@hotmail.com
---
>-----Original Message-----
>I have a custom property that as a date value and i wan't=20
to sort postings
>using that property.
>Is possible to order a list of postings using a custom=20
property?
>
>thanks,
>Gon=E7alo Bol=E9o
>
>
>.
>





[ Post a follow-up to this message ]



    Re: Sort postings by custom property  
Gonçalo Boléo


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-24-05 12:51 PM

I think i couldn't sort directly from custom properties or placeholders.
Your options is an approach i didn't think off.

Thanks.

"Mei Ying [MVP]" <anonymous@discussions.microsoft.com> wrote in message
news:1aec01c51a16$213e9780$a501280a@phx.gbl...
Hi

Not directly. You could iterate through the list of
postings and store their custom property values in a
DataTable. You can then use a DataView to sort the list in
whatever order you like.

Something like this:
PostingCollection pc = c.Postings;

//put information about the postings in a table
DataTable dt = new DataTable();

dt.Columns.Add("Name",System.Type.GetType
("System.String"));
dt.Columns.Add("PromotionStartDate",System.Type.GetType
("System.DateTime"));

DataRow newRow;
for (int i=0; i<pc.Count; i++)
{
//add a new row to the table for each posting in
the list
newRow = dt.NewRow();

//add the name
newRow["Name"] = pc[i].Name;

//add the date
newRow["PromotionStartDate"] = DateTime.Parse(pc
[i].CustomProperties["PromoDate"].Value);

//add the new row to the table
dt.Rows.Add(newRow);
}

//bind the table to the datagrid
DataView dv = dt.DefaultView;
dv.Sort = "PromotionStartDate desc";
myDataGrid.DataSource = dv;
myDataGrid.DataBind();

regards
Mei Ying
---
Blog: http://meiyinglim.blogspot.com
Book: http://www.packtpub.com/book/mcms
Contact: meiyinglim@hotmail.com
---
>-----Original Message-----
>I have a custom property that as a date value and i wan't
to sort postings
>using that property.
>Is possible to order a list of postings using a custom
property?
>
>thanks,
>Gonçalo Boléo
>
>
>.
>







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:22 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register