Thursday, August 17, 2006

Sorting an ObjectDataSource with child Classes

I found a really good article that tells what needs to be done to create a custom comparer that will allow objects to be sorted. That's about all there is to it... but it's really good.
Here's the link.

Thursday, August 10, 2006

Set Page Titles Dynamically in ASP.NET

4guysfromrolla.com is where I end up much of the time after searching for how to do something in ASP. They have some really great information on that site. One item in particular that I thought was cool is thee fact that you can set the page title dynamically with information contained in the site map control. Read the article to be enlightened.

Thursday, August 03, 2006

Order items in a ListBox


I spent some time looking for a way to rearrange the items in a list box and there my very well be a better way to do this, but this is what I came up with. I took ideas from several things I found online to arrive at this solution that best fit my needs. The "up" and "down" strings are passed in by button click events. Another little note was that in order to get the arrows to show up in the buttons I had to change the font and enable unicode. I also had to copy the symbol I wanted from the character map.

Here's the code to make it all work:

private void MoveListBoxItem(string direction)
{
switch (direction)
{
case "up":
if (productSectionBindingSource.Position!=0)
{
int OriginalIndex = productSectionBindingSource.Position;
ProductSection SectionToMove = productSectionBindingSource.Current as ProductSection;
SectionToMove.DisplayOrder = OriginalIndex - 1;
productSectionBindingSource.Remove(SectionToMove);
productSectionBindingSource.Insert(OriginalIndex - 1, SectionToMove);
productSectionBindingSource.Position = OriginalIndex;
(productSectionBindingSource.Current as ProductSection).DisplayOrder = OriginalIndex;
productSectionBindingSource.Position = OriginalIndex - 1;
}
break;
case "down":
if (productSectionBindingSource.Position != productSectionListBox.Items.Count - 1)
{
int OriginalIndex = productSectionBindingSource.Position;
ProductSection SectionToMove = productSectionBindingSource.Current as ProductSection;
SectionToMove.DisplayOrder = OriginalIndex + 1;
productSectionBindingSource.Remove(SectionToMove);
productSectionBindingSource.Insert(OriginalIndex + 1, SectionToMove);
productSectionBindingSource.Position = OriginalIndex;
(productSectionBindingSource.Current as ProductSection).DisplayOrder = OriginalIndex;
productSectionBindingSource.Position = OriginalIndex + 1;
}
break;
default:
break;
}
}

Tuesday, August 01, 2006

SQL Contacts to Exchange (Outlook)

After being given the task of making one of our application databases be the source of a public folder contact list in Outlook, I came to find that the task is not as easy as it may seem. There are about a billion different ways to do it and you can see some of them here. The one that was decided to be the best for our purposes was Stephen Toub's Outlook Contact Provider. After implementing some caching on the project, it did exactly what we needed and it works great. This basically mimics a SharePoint web service and uses a custom provider to get the contacts from a database. I ran into a little trouble because of the conversion to ASP.NET 2.0 but after those issues were resolved, it worked like a charm.