Adding glyphs to a GridViewa

In Dino Esposito’s GREAT book for ASP.NET 2.0 called Introducing Microsoft ASP.NET 2.0, he gives a good hint for adding the little up/down arrows (glyphs) to a gridview to indicate sorting direction. Well, unfortunately, he wrote the book using Beta 1 of the 2.0 Framework, and Beta 1 of VS2005. Now that we’re very near RTM, and one of his commands was made obsolete in Beta2, I had to do a little editing to it.

So, his original code:

void AddGlyph(GridView grid, GridViewRow item)
{
Label glyph= new Label();
glyph.EnableTheming = false;
glyph.Font.Name = “Webdings”;
glyph.Font.Size = FontUnit.XSmall;
glyph.Text = (grid.SortDirection==SortDirection.Ascending ?” 5″ : ” 6″);

//Find the column you sorted by
for(int i=0; i < grid .Columns.Count; i++)
{
string colExpr = grid.ColumnFields[i].SortExpression;
if(colExpr != “” && colExpr == grid.SortExpression)
item.Cells[i].Controls.Add(glyph);
}
}

There are a couple of issues with that though. The ColumnFields collection has been depricated as of Beta2, meaning it must be replaced with Columns instead. So I did that. And it worked, sometimes. On some of my grids, I would an error that the Index was out of range for the collection. After thinking about it I realized that the Items.Cells collection was not necessarily the same as the grid.Columns collection. Yeah, in a perfect world it would be, but if you’re hiding columns (like I do to make the grid more usable), then it is different. So I rewrote the for loop as follows: 

for(int i=0; i< item.Cells.Count; i++)
{
string colExpr = grid.Columns[i].SortExpression;
if(colExpr != “” && colExpr == grid.SortExpression)
item.Cells[i].Controls.Add(glyph);
}

Note that you still have to use the grid.Columns to evaluate the Sort Expression, but instead of counting the grid columns, we’re counting against the row’s cell collection.

And now, no more errors! 

Who's that Man?

So I shaved off my goatee last night. Owen gets up this morning and looks down the hall and sees me, and keeps looking (I guess thinking that he wasn’t seeing me right or something). I go into the living room, and he and Zander look at me, and Owen starts just crying. This is the first time I’ve been shorn entirely in about 3 years. Zander has NEVER seen me without a goatee and of course, neither has Lauralynn. She still hasn’t seen me, so it’ll be interesting to see how she responds to me. It’s definitely coming back soon, as this is driving me nuts.

There’s a sweet Daytona on Ebay for sale that I would love to get, but Z would kill me. I already have 1 non-running car, and if Q doesn’t pay something on the car soon, I’ll have 2. 

Hurricane Wilma

OK, so my weather geekiness comes out.

Hurricane Wilma IR Imagery

This hurricane season has been nuts, and to close it out all out, Wilma (the last name available before they start going to the Greek Alphabet) is now the strongest and fastest developing storm in the Atlantic Basin in recorded history.

From http://www.nashvillewx.com - WKRN’s (ABC2 - Nashville) Weather Blog:

A hurricane’s maximum sustained winds are usually used to determine its strength, but meteorologists also rely on the storm’s minimum central pressure. You hear us mention low pressure and high pressure in everyday weathercasts…although we tend to report the value in inches of mercury (29.98″ is considered normal). In the scientific community pressure is reported in millibars (1012 mb is normal). A hurricane is really just a tremendous area of low pressure, and the big ones can get exceptionally low. Early this morning Wilma set the record for the lowest pressure ever recorded in the Atlantic basin with 882 mb. A list of the six strongest hurricanes (according to pressure) reveals how active and strong this season’s storms have been:

1. 882 mb, Wilma, 2005
2. 888 mb, Gilbert, 1988
3. 892 mb, Florida Keys, 1935
4. 897 mb, Rita, 2005
5. 899 mb, Allen, 1980
6. 902 mb, Katrina, 2005

The good news, if there is any, is that Wilma should weaken to a category 3 (perhaps 2) before landfalling in southwest Florida this weekend.

This thing dropped 62 millibar in pressure in a little less than 6 hours.

If this weird tropical weather pattern isn’t a sign of changes, I don’t know what is. Add to that the fact that Boston has gotten over a foot of rain in a little over 2 weeks, it’s raining/thunderstorming in LA in October and snowing in Denver, and I’d say that atmospheric conditions are changing. I have this sneaky suspicion that things are only going to get worse.

House Hunting

Well, today we went out to Portland (TN, not OR) and looked at some houses. Zoni is really excited about getting a house, and while I think it’s STILL premature, I really want to get into a house. It’s FAR past time that we got out of rental situations and out of apartments. I’m hoping that American Home Mortgage can actually come through for us and get us something. Of course, we went and looked at houses in the 150s-160s, and there’s basically no way on earth we’ll be able to get that much of a loan, especially with virtually nothing down, so it was just a big tease.

We did realize though, that Portland is WAY the heck out there, and really too far away from Nashville. It would be at least a 45 minute commute in each day, each way, and while that’s short compared to some people (i.e. Bostonians, New Yorkers, etc.), it’s still just too much for me. It would end up like we were in Spring Hill where I just dreaded getting up every morning. Of course, that could have had something to do with where I was working (ahem) Dell (ahem).

Great news on this front: Chris Westmoreland called Friday and he passed the bar!!! (Now, if we could just get Zoni’s brother David to do the same thing, though in a different way). I now officially have an attorney (who can help me with closing on a house. We’ll have to work out some kind of trade for a website or something. Go figure. Hopefully, he and Sybrina will find something they like soon.

As of last Wednesday, I’m back in the office at cj fulltime. As with nearly everything, there are both pros and cons to the situation. The pros are that I can actually get a lot more work accomplished, communications with co-workers are no longer strained, and I can get some time away from the house. The cons are GAS money (visit www.nashvillegasprices.com, I’m a regular submitter for Smyrna), being away from the family and not being able to set my schedule essentially however I want. I definitely thing I’ll be more productive in the office, I already have been. I’m realizing how good of a thing it is that I went ahead and started using ASP.NET 2.0 before it goes RTM. It is SO much easier to work in, and I’ve found myself shying away from using the codebehind, even when I shouldn’t. That’s probably a bad thing overall, as codebehind is where developers live, but in this case, I’m glad to be able to do things quicker in the designer. It’s making me think more object oriented in everything, even in the MECA site. I’m taking it to base classes for my next version/redesign. This one I’m going to code first, and design second. It should make the site more user-friendly, and hopefully, more effective.

Car notes: I’m selling my DSM BOV (that’s Diamond Star Motors Blow Off Valve for the uninitiated) and injectors that I got with Quentin’s CSX. We need the funds, and I’m not gonna really ever use them. I hope they sell quickly. I’ve got to replace the power steering pump, as the ENTIRE underside of the car is covered with power steering fluid. Additionally, it needs an O2 sensor so it doesn’t think it’s running lean all the time and suck down gas like a Dyson Vacuum. Oh, and a clutch. Hey, the car has over 165K miles on it, it’s about time to replace some stuff. I just wish I could upgrade more rather than OEMing.

Hey, we went to church today! It reminded me why I want to move out of the Smyrna Ward. I just don’t feel comfortable in this ward. Of course, that’s my fault as much as anybody elses, but the overwhelming feeling of discomfort in this ward makes life difficult. Hopefully, that will be done soon.

About the author

riceboyler is the pseudonym of one Jason Clark, an IT guy who does ASP.NET and Windows Phone development from time to time, waxes poetic about VMWare, Netapp and Dell, and quite frequently posts things that have nothing to do with computers, but deal with life as a father, husband, Webelos Leader and Latter-day Saint.

Follow him on Twitter at @riceboyler.

Month List