Dave Burke : Freelance .NET Web Developer specializing in Online Communities

.Text Series Collection Code: Post Entry with Series

Since a Series object is a Category object with a different CategoryType value, adding Series to the Post Entry/Update control was an easy matter.  The Entry Admin page is shown here.

Populating a Series checkboxlist on edit is shown here, the only addition being the data layer method of GetLinkSeriesCollectionByPostID.


for (int i =0; i < cklSeries.Items.Count;i++)
 cklSeries.Items[i].Selected = false;

LinkCollection postSeries = Links.GetLinkSeriesCollectionByPostID(PostID);
if (postSeries.Count > 0)
{
 for (int i = 0; i < postSeries.Count; i++)
 {
  cklSeries.Items.FindByValue(postSeries[i].CategoryID.ToString()).Selected = true;
 }
}


Binding the series checklistbox on load shows the LinkCategory object reuse with .SeriesCollection being the only difference from the BindCategoriesList() method.  I should have passed that in the method call now that I'm thinking of it...

private void BindSeriesList()
{
 LinkCategoryCollection seriesCats = Links.GetCategories(CategoryType.SeriesCollection, false);
  foreach (LinkCategory currentCat in seriesCats)
  currentCat.Title = currentCat.Title + " [" + currentCat.ParentTitle + "]";
 cklSeries.DataSource = seriesCats;
 cklSeries.DataValueField = "CategoryID";
 cklSeries.DataTextField = "Title";
 cklSeries.DataBind();
}

Entering the series information for the post was the same as for categories except for different data layer methods.

ArrayList alSeries = new ArrayList();

int scount = cklSeries.Items.Count;
for (int i =0; i<scount;i++)
{
 if (cklSeries.Items[i].Selected)
 {
  alSeries.Add(Int32.Parse(cklSeries.Items[i].Value));
 }
}

int[] Series = (int[])alSeries.ToArray(typeof(int));
Entries.SetEntrySeriesList(PostID,Series);

Comments (0) | Post RSS RSS comment feed

Posted on 10/14/2004 8:59:00 AM by Dave Burke
Categories:
Tags:

Related posts


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke