Populating a list box dynamically

I've just had to fix a colleagues code, which had the same problem that I'd been struggling with yesterday - it's another one of those annoying quirks that has you tearing your hair out because you look at your code and even though it compiles it still wont work.

The issue was that we are trying to populate a dropdown list dynamically - using the c# funtion

dropdownlist.items.add("Text","value");

Although this does compile it didn't seem to work - I stand to be corrected. The way I got round it was to create a new listitem object and populate it with my text and value. i.e

dropdownlist.items.add(new ListItem("Text","value"));

Hope this helps somebody cus it's such an annoying thing to get stuck with - another point was that the value must always be a string - you can cast it when you retrieve it - (Convert.ToInt32(dropdownlist.selectedItem.value) but it seems to only want strings (I guess this is because the value is going to be rendered into HTML so any cast information will be obliterated anyway. A Little like the classic ASP Response.Write("Some HTML") used to work.

Blogged with Flock


Posted by: dean
Posted on: 12/21/2007 at 3:40 AM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Merry Christmas

It feels like the whole world is getting ready for Christmas, except me. I did all my shopping weeks ago, so it feels like a long wait - I get like this every year. Feels like I've given up waiting and it doesn't feel like Christmas, but I know on Monday evening I wont be able to sleep just like when I was a kid :0)





Merry Christmas Everybody

Blogged with Flock


Posted by: dean
Posted on: 12/20/2007 at 12:13 AM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

DataFormatting String {0:d}

I've had this problem a few times so I thought I'd actually get round to blogging it.

Displaying Dates on a Datagrid is a nightmare when you don't want to display the full date and time in dd/mm/yyyy hh:mm:ss format.

There is a useful little property in the datagrid items editor which allows you to specify the format of the string using {0:d} formatting.

The problem I've found was that no matter what I did, it didn't make a bit of difference to the output.  The solution after much googling was was set one of the other properties..

The trick is to set HTMLEncode to False - as if by magic it works.

Actually it's not magic - the reason it works is that by default your data is html-encoded before the string formatting is applied - switching off html-encoding stops this happening and allows you to format it how you wish - this post explains in more detail:

http://tinyurl.com/hx8jb


Blogged with Flock


Posted by: Dean
Posted on: 12/17/2007 at 1:11 AM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Assumed consent is evil and maybe illegal

Assumed consent is evil and maybe illegal

One of the best ways for an internet-based company to enter the Social Media world is through the creation of a Facebook application. A successful app will drive traffic to the company's native site, create direct sales, and promote online reputation.

So, what exactly is meant by a Facebook app? Well, it could be a simple as the Vampires application which allows members to "bite" one another and become vampires. This application is fun, simple, and has gone viral (in the sense that it has become very popular). The application is monetized by way of advertising horror movies in the application's interface, and because Facebook is all about sharing, all of one's friends can see one's Vampiric status via the same interface.

But now complaints regarding privacy are starting to surface in regard to these apps. Facebook applications can be based solely on direct sales. Companies like Overstock.com allow--or should I say encourage--Facebook users to purchase from their website through their application without ever leaving Facebook.com. The problem is that purchase information is being shared. After making a purchase, the Overstock.com app displays a small box in a corner of the browser interface following a transaction. This box alerts users that information will be shared with other Facebook users unless they click on it to negate that information form being shared. The box fades away after a half minute or so, after which consent is assumed, and all your friends can see what you bought.

I'm no lawyer, but that sounds kind of "iffy" to me. And, even if it is a legally binding procedure, it certainly isn't going to do much for customer satisfaction! There are, evidently, other large e-commerce sites with similar or identical interfaces, and my instinct is that Facebook and these large companies will solve the problem quickly. It makes a good example, however, of social media gone awry. The term "social" does not automatically imply that sharing is the default; part of being social is having the choice to share or not share. Purchasing things, especially during the holidays, often involves gifts, and the surprise of a well-chosen gift to a friend (who may well be in your Facebook world) is as social as it gets.


Posted by: Dean
Posted on: 12/1/2007 at 10:51 PM
Tags: , , ,
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed