Thursday, 4 February 2010

I don't usually DO books!

With so much new emerging technology over the last few months I thought I would invest in some new reading material to try and get to grips with some of this new technology. I have to confess I'm not a great reader, I tend to dip in and out of books to get the information I need and then put it down - I find that's the way I learn best. However, I have purchased one book that I am absolutely fascinated by and comparitively speaking.............. I can't put it down! So, what is this read that has me so gripped? It's a book by Bob Walsh called "The Web Startup Success Guide" (ISBN 978-1-4302-1985-9).

I would recommend this book to anyone starting, about to start or even running in its infancy a web or software company. It's not that it has any definitive answers but it has certainly made me think, look at and re-assess some aspects of the direction I am trying to take my company Maiden Software.

Tuesday, 2 February 2010

XPath 1.0 Query and ends-with

I was trying to find a set of nodes in an xml document that ended in "id" (personid, addressid etc). Upon discovering that version 1.0 of XPath does not support the ends-with expression that is supported in version 2.0 it was time for a work around!

After much research on the web I found that the only real way to do this was to use the substring function thus:

xmldoc.SelectNodes("//*[substring(name(), string-length(name()) - 1) = 'id']");

This delivers back a node set that was exactly what I wanted!

Sunday, 31 January 2010

Always learning

Having worked for many years with ASP.NET GridViews I have never noticed before that when you use a ButtonField ( for instance) as a column in the GridView, when handling the event in the code-behind in the event created for this (mygrid_RowCommand(object sender, GridViewCommandArgument e) for instance) that e.CommandArgument is the offset of the row ON THAT PAGE!!! So if the gridview is paged at 20 per page, the command argument will be 0-19. So, when you are trying to recover the DataKeys for a paged gridview, ASP.NET has worked it all out for you so there is no need for code like:

gv.DataKeys[e.CommandArgument + (gv.PageIndex * gv.PageCount)]

all you really need is:

gv.DataKeys[int.Parse(e.Command.ToString())] - and job done!!!

As I say, always learning something!!!