16 Apr 2007

GridView Row-Click

A simple way to add "select on row-click" functionality to GridView without causing Event validation errors:


protected override void OnRowCreated(GridViewRowEventArgs e)
{
base.OnRowCreated(e);

if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onClick"] = "this.style.cursor = 'wait';"
+ Page.ClientScript.GetPostBackEventReference(this, "Select$" + e.Row.RowIndex.ToString(), true);
}
}


And how do you handle the click? Just hook up to the GridView's SelectedIndexChanged event handler and check the GridView.SelectedValue property.

ps. for row-hover and striping fun, why not use JQuery? Just implement the grid's RowStyle.CssClass (e.g. set it as 'zootGridRow') and set some style directives to handle the following classes...


$(function() {

// Implement grid-row striping
$('#myGrid .zootGridRow:odd').addClass('zootGridAlternateRow');

// Implement grid-row hover animation
$('#myGrid .zootGridRow').hover(function(){$(this).addClass('zootGridRowHover')},
function(){$(this).removeClass('zootGridRowHover')});

});

9 Apr 2007

Roman Holiday

Sarah and I went to Rome for Easter 2007 - Friday to Monday. Wow! What a city. We saw loads of amazing stuff that really blew our minds. We think we have archaeological history in Britain - but in Rome it's still standing! Amazing.

Anyway, click this post's title if u wanna see pics.

Just want to give mad props to the hotel we stayed at: The Mecenate Palace. This is conveniently located within suitcase-dragging distance from Termini train station, and is just off the Plaza di Santa Maria Maggiore - which the terrace roof garden overlooks for breakfast. We booked in there via Last Minute and managed to get a lovely Executive Floor room - all wood floors and a jacuzzi bath. Really good.

Oh and boooo to the Restaurant Diocleziano on the Via Viminale, where we had crappy italian food on the first night, which I didn't think was possible!
If I helped you out today, you can buy me a beer below. Cheers!