Daniel Fisher (lennybacon.com)

SOA, DATA & THE WEB

Complex Databinding

I just finished writing some ASP.NET code where I also typed the following lines: 

 <ItemTemplate>
	<asp:Image ID="IsOnline" 
	runat="server" 
	ImageUrl='<%# GetImageUrl((MembershipUser)Container.DataItem) %>' 
	/>
</ItemTemplate>

...

protected string GetImageUrl(MembershipUser user)
{
	if (user.IsLockedOut)
	{
		return "~/images/BadUser.gif";
	}
	else if (!user.IsApproved)
	{
		return "~/images/GreyUser.gif";
	}
	else if (user.IsOnline)
	{
		return "~/images/OnlineUser.gif";
	}
	else
	{
		return "~/images/OfflineUser.gif";
	}
}

Before I shutdown my machine I fetchted Mail and Feeds when i ran accross this posting by ScottGu pointing to Fritz Onions Blog.

;-)

Comments

Write a comment