Wednesday, June 20, 2007

Developer Guide: ASP.NET Grid View Part 1

I've decided to start collecting my accumulated knowledge regarding the ASP .NET GridView control. This is really for my own edification because I killed to many brain cells in college and now I can't keep everything in my head anymore. However, I do hop e that someone finds this useful so I'm going to try and write it at a fairly high level over a series of posts. I plan on covering the following topics:

  1. What is the GridView control

  2. Common Properties

  3. The Columns collection

  4. GridView events - what you absolutely need to know

  5. Tricks of the Grid

The GridView Control

The GridView control is an ASP.NET control for formatting a set of data in a consistent manner. In web development the most common task asked for is the layout the results of a database query into a table on screen and allow the user to interact with that data. This used to involved tons of code, paging routines, and it caused a huge mess.

The GridView control simplifies this way, way, down while still allowing you some very fine grain control. At its most basic a GridView control requires 1 markup line and 3 code behind lines.

Markup:


Code Behind:
string sql = "Query"
GridView.DataSource = Your.DataAccessLayer.QueryAsDataTable(sql);
GridView.DataBind();

Done. Yeah, yeah I took a shortcut and ignored things like in-page DataSources and I didn't actually tell you how to build your Data Access Layer, but these are things I wax poetic on later.

Monday, June 18, 2007

You should be daaaancing - yay!

Progress is a beautiful thing. Tim came over tonight and we busted our butts for 5 hours. See that pretty little box on the right? Thats what we got for our 5 hours. Yeah, you cant see it, but its our widget. And its wonderful.

This weeks developer tip: the K.I.S.S. development method. K.I.S.S. stands for Keep It Simple Stupid. My high school physics teacher taught us this when we were learning kinematic motion. It's the principle of keeping things as simple and straight forward as possible, but no simpler. It applies to development during refactoring of a functional unit. Factor the reusable components and leave the rest alone. Don't refactor a loops body if that loop body will not be used elsewhere. It might make for a function that is larger than one screen, but it makes it easier to maintain in the future.

Your Orioles update for June 18, 2007: Sam Perlozzo is out. 24 hours ago I would have cheered this move. But now I'm a little leary. I feel bad for Sammy on a personal level, but he wasn't getting the job done. He might have been a hometown guy and managing my beloved O's might have been his dream job, but he wasn't very good at it. The Warehouse is trying to get Joe Girardi to fill Sam's place and that would be a dream come true. But then again Girardi was a Yankee....MF Yankee's.

Wednesday, June 13, 2007

Fancy Smancy

So my partner in crime figured out how to have a widget that is essentially an iframe into an ASP.NET page. Happy day! I was terrified that I'd have to turn my C# back in for VB Script again. Yick. Details later on when I get them from him.

At work today I got to:
- twiddle my thumbs
- write another boring report for accounting
- fix another apostraphe bug (apos. are reserved characters in SQL)
- and work on my big project

Why is it business development always changes the requirements on you after you've developed version 1? And not just changed the requirements, but screwed them all to hell! I hate management - and its not just my current crop of bosses, its every upper management (save Jeff, he was the shit) suit I've ever worked for.

Random SQL tip: Always replace an ' with '' before including it in any sort of insert, update or select statement. And remember, because you didn't think to try it your clients are certain to do so. Check every textbox field or foul characters. Oh and if you're like me, run your text thru a spell checker.

And on your Orioles watch: 7-4 loss to the Nationals. That game was so boring I feel asleep on my couch. Yes, the couch with a wooden board in the middle that makes my butt ache in 10 minutes. I digress. So here is your situation: bottom 9th, 1 out. Your "power" hitter has just launched a ball over the left field wall to bring you within 3 and the middle of the order has put a man on first and second. So the tying run is standing at the plate with a bat in hand. Who do you send up there? Queue Jeopardy music.
A) Paul Bako - your backup catcher who has been forced into starting w/ Ramon out
b) Jay Gibbons - your used-up left fielder with attitude problems who used to have power
c) Kevin Millar - the "heart" of the team who also happens to hit for power (sometimes)
d) Freddie "I-Only-Pinch-Run" Bynum - ok the nickname should give that one away

I eagerly await your answers. Is it football season yet?

Tuesday, June 12, 2007

My attention span kinda stin - oooooh a shiny

It's time. Time to break down and buy a laptop. I'm finally getting some income from the CENSORED website and while I was planning on using for Stephanie's ring I think its better spent on a new laptop. And probably one without wi-fi internet.

Why you ask? Because I cannot turn off World of Warcraft and get my work done (wassup Poets?). It's that simple. If I get a laptop with a crappy video card, go sit in an uncomfortable seat in Starbucks where there is no internet I might actually get some work done.

Then again, there is always solitaire.

And on your Orioles watch: The Birds had the night off last night, and Angelos (hereafter, PA) missed another opportunity to Fire Sam Perlozzo!

Testing 1, 2, 3

You know, I swore I'd never start a blog. I hate MySpace (I'm a Web Applications developer, it offends my delicate CSS sensibilities). Facebook, while cleaner, isn't much better in terms of content. Social Networking, to me, is just stupid. But, when you're given some cash to create widgets you need someplace to test them. So I started a blog.