Monthly Archives: May 2008

Bulk Inserting Data with the ListView ControlMatt Berseth

I am working on a project that needs a new screen for bulk entry tasks.  We have a few business scenarios coming up where we have people inputting 5 to 8 records of data at a time.  I met with a few of our analysts last week and hashed out a rough outline of what they were looking for.  About 10 times or so during the 30 minute meeting some form of the phrase 'kind of like excel' was mentioned.  Our data entry personnel are familiar with excel and our analysts thought an excel styled grid would make a lot of sense.  'An excel grid with a Submit button’ was the phrase I had underlined twice in my notes. 

I wasn't too worried about the grid's styling, but I wasn't quite sure what the best way to handle the 'bulk insert' requirement.  Most of our other grids require an explicit mouse click to insert an item – and often times this click includes navigating the user to a separate page that is made to handle inserts.  Of course for mass data entry tasks this can get a little old – tabbing through the cells is much nicer.  So I took my notes back to my desk and started building a small prototype.  You can check out the live demo to watch the grid in action.  And a few of my implementation notes can be found under the screen shots below.

Live Demo (IE6, IE7, FF, Opera) | Download

image 

Configuring the ListView

My excel styled grid only has one mode – bulk insert.  It would also support mass updating as well, but for our use cases this is a one way data stream.  I want to use the ListView because I like how the templates are structured, but the ListView doesn’t natively support bulk inserting data (the ListView supports defining an InsertItemTemplate, but the ListView will only render this template once – so this template isn't useful for my scenario).  I decided I would try using the regular ItemTemplate, but render elements that support editing instead of the usual read-only controls (i.e. TextBox's instead of Labels).  I still use the Bind syntax because I want 2 way databinding, but because I am using the ItemTemplate for an insert scenario I will be responsible for telling the ListView when my data needs to be moved out of the controls and back to my data source.  Below is the markup for my ListView.

image

 

Setting Up My DataSource

Next, I setup my data source.  For this example I am using the ObjectDataSource control.  When my data source is first bound to the ListView, I want to render placeholder objects for 8 records (i.e. I want my grid to show 8 empty rows by default).  So when my Select method fires, I return a collection that contains 8 Customer objects that have their property values set to their default values (null strings for my example).

image

Next, I handle the Submit button's click event handler and loop through all of the ListViewDataItems and invoke the ListView's UpdateItem function which will cause the Update method on my ObjectDataSource to fire – moving the data back out from the controls and back into memory.  Finally, after the data is moved back to memory, I persist the batch to the database (for the demo I am persisting it to memory, but when this page goes live it will obviously be put in the database).

image

To make sure I don't persist records with all empty values, I added a validation check to my Customer business object that makes sure the object has at least one data value before the row is submitted.  If validation passes, I move the customer data into the database.

image

 

Toggling the DataTable’s Skin

For a bit of flair I included a couple of radio buttons for changing the grids theme from the default 2003 style excel shown below (found a nice article here on creating this skin) to the 2007 version which is a bit softer (see screen shot at the beginning of the article). 

image

To change the grids skin I attached event handler’s to the radio button’s click events and use the Sys.UI.DomElement.addCssClass and removeCssClass to toggle the CSS class that is applied to the grid.  Below is the JavaScript that does this bit of work for me. 

image

That's it.  Enjoy!

Update To Deep Zoom Composer for Silverlight ReleasedDan Wahlin’s WebLog

dzcicon

Microsoft just released an update to the Deep Zoom Composer that works with Silverlight 2 Beta 1.  If you're unfamiliar with the "deep zoom" technology it provides a way to zoom in and out of images.  When I say "zoom in" I mean zoom way in.  Check out the Hard Rock Memorabilia site for an example of the technology in action.

For detailed information about the new release visit blogs.msdn.com/expression/archive/2008/05/03/an-update-to-deep-zoom-composer.aspx.  Here's a summary of the new features listed on the blog along with some images they provided:

  •  Improved Exporting – The previous release created a file containing all of the images that you'd like users to be able to zoom in and out of, but didn't write any of the Silverlight code to jump start the process of using the MultiScaleImage control.  The new version adds that capability by creating a working Silverlight project after images are exported.

exportDZC

  • Better Design Experience – The new version provides enhancements for arranging your photos in the Deep Zoom Composer.  Highlight groups of images (or a single image) to move them all at once and get snap and guideline capabilities.

imageSnapping

  • Updated Collections Export – What you see is what you get.  If you arrange images a specific way they'll be shown that way in the browser with this updated release (a previous issue was fixed).
  • Greater Access to Help – An easier way to post help to the forums (as opposed to the Deep Zoom Composer Blog) has been provided.

AVG Free Anti-Virus 2008 Released, Much Improved [Featured Windows Download]Lifehacker

avg-free.pngWindows only: Popular freeware anti-virus application AVG Free recently updated to AVG Free 2008. Aside from a general interface overhaul and faster performance, the updated anti-virus scanner has added several new features with a focus on web security. AVG is always at the forefront of the freeware anti-virus category, so unless you don’t run anti-virus software, it’s a great alternative to crappy Windows software.




Next Tab Keeps Your Tabs in Context [Featured Firefox Extension]Lifehacker

next-tab.pngFirefox only (Windows/Mac/Linux): Firefox extension Next Tab adds an option to the right-click context menu to open a link in a new tab directly next to the current tab. If you’re the sort who’s still got 10 tabs open on a light day, you know how quickly your reading can get disorganized. Next Tab helps keep those tabs in context and next to the tabs from whence they were launched. Next Tab is free, works wherever Firefox does.

Next Tab [Firefox Add-ons via Firefox Facts]




TweakRAM Memory Optimizer Free Today Only [Featured Windows Download]Lifehacker


Windows only: Instead of dropping cash on a new stick of RAM for that old computer, go grab a free license for the normally $20 memory manager TweakRAM—today only. TweakRAM speeds up your machine by optimizing Windows memory management, and when your computer slows to a crawl, you can use TweakRAM to manually free up memory. The developers say:

TweakRAM defragments your computer’s memory, increasing the efficiency of your CPU and Motherboard caches, recovers memory leaks from poorly behaved applications, flushes unused libraries temporarily out to disk and so on. By all this optimization tricks your favorite applications and games will run faster and efficiently even on old computers.

TweakRAM did in fact free up memory on my Windows PC, according to its own report, though I wasn’t able to test it in a real-world, total PC slowdown situation. The Giveaway of the Day web site is featuring TweakRAM today only, which means you’ve got about 12 hours or so to head over there, download, and install the free activation version. Otherwise, TweakRAM is available as a free trial, and costs $20 for a personal license, for Windows users only.

TweakRAM 6.2 [Giveaway of the Day]




Slipstream Service Pack 3 into Your Windows XP Installation CD [Windows XP]Lifehacker


Next time you wipe your PC’s hard drive clean and reinstall Windows with that old installation disc, you don’t want to connect your fresh, unpatched and vulnerable system to the internet only to download 176 new updates from Microsoft. If your XP installation CD is older than 2004, once your system is online, you’ll have to wait for hefty service packs to download, chained to your mouse while pushing the Next button, watching progress bars, and rebooting multiple times. Wouldn’t it be better to start your installation, head out to run errands or grab coffee, and come back to an up-to-date system before your system gets online? It’s possible, using some free software and a blank disc. After the jump, I’ll show you how to create an automated, customized XP installation CD or DVD, that includes Microsoft’s official-but-not-released Service Pack 3 for Windows XP.

Note on the current status of Service Pack 3: As of May 2, 2008, Microsoft has released Windows XP Service Pack 3 to PC manufacturers, but due to a last minute bug discovery which has to do with software for businesses (not home users), they have delayed the “release to web.” This means they are not yet pushing it to users via Windows Update, and they have not yet published a Microsoft Download Center page for it. However, the official SP3 file is available for download on Microsoft’s servers. Here’s the direct link to the English version. No word on when SP3 will appear on Windows Update, but no doubt it will be soon. For more on what you get with the new service pack, here’s our complete field guide to SP3.

Why make a “slipstreamed” disc?

Maybe you’re the type who can’t fathom being absent while Windows installs, unable to prune all the unnecessary applications and features, customize the desktop, set up user accounts and install needed drivers. Well, you and I have a lot in common, but we can both enjoy what nLite, a free slipstreaming utility, can do:

  • Pre-configure and tweak Windows—Nearly every power-user setting, from hidden file showing to deep registry hacks, can be set from the get-go.
  • Pre-install drivers and printers—No more searching through the Nvidia, ATI, or printer manufacturers' sites for the exact package after install.
  • Strip your system for speed—Adam's already showed us how nLite can help you trim Windows to its bare essentials, which not only saves disk space and frees up memory, but saves you the time of disabling and removing the superfluous stuff later (and clicking “Yes” on every “Are you sure …” prompt).

What you’ll need

Note for Vista users: There’s a similar utility for creating a slipstreamed Vista DVD, vLite, which got the step-by-step treatment from Digital Inspiration. That tool, however, doesn't allow for half as much customization—not yet, anyways.

Getting started

nlite_1.jpgAfter you’ve installed nLite, load your installation CD into your disc drive and make sure you’ve got your 25-character product key handy. Launch nLite, click to the next screen, “Locating the Windows installation.” Before you go further, create a new folder somewhere on your computer, at the hard drive root (as in “C:”) if possible. Click “Browse,” select your CD drive, and you’ll be prompted to copy your CD to a folder. Select the folder you created, then wait for the copy to finish.

nlite_3.jpgNLite’s next screen will ask what you want to customize on your install disc. If you only want to update to SP3, only click the “Service Pack” button. But unless you love answering questions and never touch a setting in Windows XP, you’ll want to flip all the switches green and click “Next.”

nlite_2_2.jpgNow nLite will ask for slipstream files, or packages you want to integrate into the installer. You’ll always want to have the latest service pack available, since, for instance, Service Pack 3 incorporates the fixes made in SP1 and SP2, so it makes them unnecessary. If you grabbed the latest beta of nLite, you’ll see a Service Pack 3 already offered for integration, but it’s an older release candidate. Hit the “Choose” button, select the executable file you downloaded from Microsoft with the seriously long file name, and give nLite a few minutes to implement it. When you see the version number change, hit “Next” and move on.

wul_cropped.jpg"Hotfixes and Update Packs" is for all the tiny little Windows Updates between service packs. If you're including SP3, you can pretty much skip this part. But in the future, and for those not jumping onto SP3, I recommend running WinUpdatesList. You'll see a list of all the updates you've installed, and sorting by date and type should show you what you've installed since the last service pack. Right-click on an update, and you'll get a link to a related Microsoft Knowledge Base article, where you should be able to download the fix directly and patch it into nLite. You can also roll executables for Windows updates—like Internet Explorer 7, which (still!) doesn't install by default—into your disc.

Click "Next," and you'll see an identical screen for drivers. If you know where to find the .INF files that connect your hardware to Windows, you can roll them into your install disc, but be warned: a small printer INF increased the final size of my ISO by at least 200 MB—I'm still trying to figure out why, but if you encounter similar problems, simply throw the driver installation files into spare space on the disc (more on that soon).

Customize your install

nlite_4.jpgYou start really making your XP system your own on the next screen. The “Compatibility Window” that pops up can protect you from yourself; unless you’re sure you can do without an item, you’ll want to leave it checked. Behind it, the “Remove Components” section is where you can pull out all the stuff you don’t ever use or don’t have. Most of the savings are small in hard drive size, but keep your system from clogging with services and drivers it doesn’t need. Among the almost-guaranteed safe removals:”Briefcase” from Accessories; most of the non-red items in Hardware; Keyboards and Languages that you don’t ever plan to use; “Tablet PC” from Multimedia; and MSN Explorer and Windows Messenger from Network.

nlite_5.jpgUp next is the “Unattended” section, if you checked it, and this one requires attention to detail. If you want to set and forget your XP install, change “Unattended Mode” to “Fully automated,” but then move slowly through every tab, filling in every section you’d expect to get prompted for during install. You can fill out your Product Key in advance here, and you’ll also want to check “Skip OOBE” (Out Of Body Experience, or the introduction tour). Fill out all the name fields in “Users” and “Owner and Network ID,” and make sure to set the time in “Regional.” Once you’re content you’ve pre-empted your installer, click “Next.”

nlite_7.jpgYou can pretty much leave the "Options" pane alone, although I enable the "merge" option by way of hoping for a smaller package. The "Tweaks" options are up next, and while I can't tell you how to customize your desktop, I'll note that you can basically set up your desktop, Start Menu, Internet Explorer and lots of other Windows tweaks from these prompts. Check the bottom bar for descriptions, and fear not—all of these can be undone, and we've posted a good many here at Lifehacker.

nlite_6.jpgHit "Next," and you're almost done—click "Yes" to start the bundling process. Once that's finished (about 7-10 minutes on a faster computer), you can click through to make or burn an ISO file. Before doing that, gather up any files you want to keep on the disc, like that finicky printer driver or your favorite app installers, and place them in their own folder in the directory where you copied your original XP CD to. Now hit “Make ISO,” choose where to save the image, and then burn it to CD or DVD using your favorite utility, like the free ISO Recorder.

You’ve now got a CD that’s completely up to date, and installs by itself (once you get past the initial blue-and-white loading screens, that is). You might have to run through nLite a few times if your images turn out bigger than you want, but you can always create a bootable DVD if needed.

What changes, updates, or advanced features have you slipstreamed into your Windows disc? What do you still wish you could have loaded onto your Ultimate No-Touch Install CD? Let’s hear ‘em both in the comments.

Kevin Purdy, associate editor at Lifehacker, won’t be pulling any more late-night emergency XP re-installations for himself or desperate friends. His weekly feature, Open Sourcery, appears every Friday on Lifehacker.




Wood Filler BasicsRockler Woodworking Blog

Wood filler, grain filler, wood putty – what’s it all mean? Judging by the raft…

Turn off Session State if you’re not using it.NET Tip of The Day.org

Since ASP.NET Session State is on by default, you pay the cost in memory even if you don't use it. If you're not using Session State, turn it off and save yourself the overhead. There are serveral ways to do this:

  1. If you're not using Session State at all, turn it off completely via web.config file:

    <system.web>

        <sessionState mode=Off></sessionState>

        …

  2. If you're using Session State, but it's required only for a few pages, then first turn it off for all pages:

    <system.web>

        <pages enableSessionState=false>

        …

    then enable it for a specific page:

    <%@ PageEnableSessionState=”true” %>

 

P.S. obviously such optimization makes sense only for high-traffic web sites.

Get Free Wi-Fi Access on Your Laptop at Starbucks, Barnes and Noble [Free Wi-Fi]Lifehacker

free-wi-fi.pngOur gadget-obsessed brothers at Gizmodo report that many AT&T hotspots—including Starbucks and Barnes and Noble—have started offering free Wi-Fi access to iPhone users. With a little ingenuity, the same free Wi-Fi access can be granted to your laptop. Using it from your iPhone, you just connect to the hotspot and give the site your iPhone number. To get the same access on your laptop, the key is to fool the hotspot into thinking your browser is still an iPhone. Here's how:

To masquerade as an iPhone, you’ll need to tweak your browser’s user agent, which web sites use to identify your browser when you connect to the site. In Firefox, you can install the previously mentioned User Agent Switcher. In Safari, you can select the iPhone user agent through the Develop menu (which you can enable by navigating to Preferences -> Advanced and checking "Show Develop menu in menu bar." Likewise, Opera has user agent switching built in. On the non-Safari browsers, you'll have to manually add a new iPhone user agent like so.

new-user-agent.pngNow that you’re all set up with your spoofed iPhone user agent, head to the hotspot page and enter your iPhone number (or, if you’ve got permission, maybe the number of an iPhone owner you know).* Once you’re done, you should hopefully have free hotspot access from your full screen rather than your tiny iPhone screen.

I haven’t actually been able to verify this yet (though there are reports of success), so if you give it a try, let’s hear how it worked for you in the comments.

*One Gizmodo reader using his unlocked iPhone with T-Mobile reports that entering his T-Mobile number worked, but your mileage may vary.




Unlock USB Support for VirtualBox in Ubuntu Hardy Heron [Ubuntu]Lifehacker

vbox_cropped.jpgVirtualBox makes virtual installations of Windows and other operating systems easier than you’d think in Linux (as mentioned in our second look at Ubuntu 8.04, “Hardy Heron”), but the key missing feature from its free, open-source edition is USB support. Your iPod need not feel shunned from Linux land any longer, however, as the Ubuntu Unleashed blog offers step-by-step instructions on installing and configuring VirtualBox with support for plug-in devices. It’s specific to the newest Ubuntu and a little bit more than the “five easy steps” promised, but it should only take a few minutes to unlock the bridge between your system-in-a-system and all your gadgets.




WP Like Button Plugin by Free WordPress Templates