ASP.NET Gridview and CSS

Here’s a quick tutorial on combining a style sheet with an ASP.NET gridview control.  The only reason I’ve picked on the Gridview control is that I’m using it extensively at the moment.  This is something that threw me a little when I first had to use the Gridview with a CSS file.  Whether I was being particularly dense or not I’m not sure, but for what it’s worth, here’s a quick ‘getting it working’ tutorial.

This is far from complete – let’s just call it a traditional web development mindset being applied to ASP.NET.  I always find that making the initial breakthrough’s the hard part – I hope this short article eases the way for you!

The tools…

I’m assuming you’re using Visual Web Developer for the purposes of this tutorial.  If you’re doing it ‘the hard way’ with just a programmer’s editor then I’ll detail that separately.  In each case ‘Website’ is the name of the folder containing the files that make up the website.

Within Visual Web Developer

On the default.aspx page, go in to Design Mode and drop a Gridview object and a data source object to suit your data source (this will depend upon what you’re using for your data for the view, and isn’t relevant to the tutorial – the CSS side of things will apply to all data sources).

Now, right click on the Website folder in the Solution Explorer window.  From the displayed menu, select ‘Add ASP.NET Folder, and from the newly displayed sub-menu select ‘Theme’.  A folder called ‘App_Themes will be created, and within it a new folder called ‘Theme1’ will be visible, available for you to type in the name of the display theme that you’re going to create.  (For the sake of this tutorial, an ASP.NET theme is a collection of visual effects that can be applied to a website and the controls therein – including style sheets)  With startling originality, we can call it ‘Test’.

Now, right click on the newly created ‘test’ folder within the ‘App_Themes’ folder, and select ‘Add New Item’.  A dialogue will be displayed that will allow you to select, amongst other things, a Style Sheet.  Select this, and rename the style sheet added to the Test Theme to ‘Test’.

We now have an empty style sheet – open it up and enter the following:

.gridtitle {color: fuchsia;}

This adds a CSS class to the Style Sheet called ‘gridtitle’.  All it does is sets the colour of the text to a rather disgusting (but definitely noticable) fuschia pink colour.Obviously, in the real world we would now proceed to put in to our style sheet anything we pleased.  But for the purposes of this tutorial, this will do.Now, back to our Default.aspx page.  Select the ‘Source’ view.  Modify the first line of the file to read as follows:

<%@ Page Language=”VB” AutoEventWireup=”false” CodeFile=”Default.aspx.vb” Inherits=”_Default” StylesheetTheme=”Test” %>

All we’ve done is added the StyleSheetTheme attribute with a value of ‘Test’.  This basically attaches the Style Sheet from our Test theme to the page.Now, we have a Style Sheet, containing a class.  We now need to tell a particular part of the Gridview control to inherit the visual style set by this class.

For the sake of demonstration, find the <Headerstyle> tag within the asp:Gridview structure, and modify the tag to read as follows : <HeaderStyle CssClass=”gridtitle” />

This assigns the gridtitle class from our Style Sheet to the Header style.If you run the page, you will see the Header Row of the Gridview rendered in bright pink. And that’s how to do it!

Using a Text Editor

If you’re constructing the site using a text editor, then the syntax used is as above.  the main thing you have to do manually is to create the necessary folder structure under the ‘Website’ folder to support the Themes.  In the same folder as the Default.aspx file, create a folder called ‘App_Themes’.  Now, within that folder, create a further folder called ‘Test’.  Within the ‘Test’ folder create a stylesheet file called ‘test.css’ and define the gridtitle class within it.

Now return to the Default.aspx file and make the changes to it outlined above.

Again, that’s all there is to it!

The Bus Book – w/c 31st March – Libra

Don DeLillo’s Libra takes on the great rift in the American psyche; that which opened up on 22nd November 1963 when Kennedy was assasinated.  Whatever the nature of the man, one thing became true form that point on – that bad things can indeed happen to and in the Home of the Free.

This is a labyrinthine book on a number of levels.  It is a semi-fictional account of the life and death of Lee Harvey Oswald.  The author makes no attempt to separate fact from fiction; indeed, as Oswald has entered the status of myth it would probably be nigh on impossible to do so.  The book follows Oswald’s youth, his time in the US Marines, his assignment to the U2 base at Atsuga, his defection, his return, and the fateful day in November 1963 when he and history collided on Dealey plaza.

The book also follows the activities of three disaffected CIA veterans of the Bay of Pigs invasion, and how their initial thoughts of a faked assasination attempt on JFK eventually give way to soemthing more sinister.

Parts of the story are seen through the eyes of Nicholas Branch, a retired CIA agent who is now tasked with assembling the definitive story of the assasination of JFK.  He is provided with all sorts of information and meta-information about the assasination – even down to the dreams of witnesses to the event.  A CIA information specialist he knows as ‘The Curator’ keeps the information coming, thickening the fog and building new paths in to an already infinitely complex maze.

Over the years it is quite possible that no other single event in human history with one exception has been examined so closely with so little agreement as to what actually happened.  And the other event is the Crucifixion.

The rest of the book is almost stream of conciousness from Oswald, the CIA agents, Jack Ruby and all the other bit part players in the drama.  The labyrinths I mentioned are of information, conspiracy, identity and intention.

 It’s a stunning book.  I am actually quite haunted by parts of it.  As a Sunday Times critic wrote – “This, you feel, is America, and the bad news starts here.” CS Lewis, who wrote about the ‘Inner Ring’ of people more in the know than you are, also died on 22nd November 1963; I’ve often regarded this as ironic. 

Read it – it reminds me, for some strange reason, of ‘The Name of the Rose’.  I have no idea why.

A final observation…I bought this book in Leeds and started reading it on the evening train back to Sheffield.  A young lady opposite asked me what I was reading, and I told her.  A young man in a neighbouring seat then looked up and showed what he was reading; The Illuminatus! Trilogy – a novel about an all-encompassing conspiracy.  Whether The Curator would forward notes on such a random meeting to Nicholas Branch…who knows.

The guilty pleasure that is H P Lovecraft

Over the last couple of days I’ve taken a break from Don DeLillo’s ‘Libra’ and have returned to one of my all time favourite horror / science fiction writers, H P Lovecraft.  In particular, I’m re-reading his novella ‘The Case of Charles Dexter Ward’ – an everyday tale of international grave robbing, ghoulish possession and dealings with dark forces, spread over the centuries.

HPL is a definitely un-PC writer to admit to enjoying.  Even as a fan there are some phrases used that today slap you in the face as being patronising or racist, but given the attitudes prevalent in much fiction in the first 25 years of the 20th Century, I’m willing to cut some slack.  His ‘purple prose’ is well known – just mention the words eldritch, un-nameable and squamous as adjectives to anyone with a passing knowldge of his books, and you’ll immediately elicit his name.

I recently bought replacement volums of his stories – my existing ones had fallen apart after 20 years of reading.  The first time I read any Lovecraft at all was in a Corgi edition in my teens – I remember the book as having a purple cover – very apt, I thought – and it was part of a ‘Science Fiction Classics’ series.  The first stories of his I remember are not, oddly enough, from the C’thulhu Mythos – they were ‘The Colour out of Space’ and ‘The Shadow out of Time’ – pretty much straight science fiction in most respect.  His Venus set ‘In the Walls of Eryx’ was pure 1930s science fiction, with the ilmage of Venus as an overgrown jungle world.  Once I got hooked in to the C’thulhu mythos, it was downhill all the way.  I also have a neat collection of ‘Mythos Stories’ from other authors which are great fun, and wrote my own Necronomicon related short story set in Victorian England.  Great fun!

As for the Mythos, it’s struck me recently that many of the Mythos stories I actually like best are not by Lovecraft himself!  I think one of the amazing things about the Mythos structure is how it’s been used (and occasionally abused) by an incredibly wide range of writers; just as most writers will do a Holmes Homage, most science fiction authors will end up doing a Mythos related tale somewhere along the way.  My favourite Mythos tales probably include those of Stephen King (‘Crouch End’) and Colin Wilson – particularly his ‘Return of the Lloigor.

I remember some years ago killing time in London one evening (during my film making days) in a Cybercafe on Tottenham Court Road writing a Mythos tale based around a creature that could inhabit electronic networks.  Oddly enough, the email in which I sent the story to myself mysteriously disappeared in transit.  It did make me wonder…

Back to Charles Dexter Ward – true Gothic Horror.  There is a section of the book where even now I have to sit back and think hard, following the disguises and double identities of the characters in the novel – but it’s a great story.

If you’ve never read any Lovecraft, and you don’t mind a bit of prose that is slightly purple, I suggest you start with ‘The Call of Cthulhu’ to kick you off on the Mythos stories.  ‘The Music of Erich Zann’ is an interestingly understated short story that always reminds me of H G Wells’ ‘The Platner Story’.  ‘The Mountains of Madness’ is a good read as well – set in the Antarctic and deals with the discovery of ancient alien life on Earth (part of the Mythos).

In the words of an old newspaper review…go forth to HP Lovecraft and shudder!

The Bus Book – w/c 24th March – The Social Entrepreneur: Making Communities Work

Andrew Mawson (now a Cross Bencher in the House of Lords) has written a very important book with this work.  It chronicles his experiences in Bromley-by-Bow, an impoverished area of East London, from his arrival there as a United Reform Church Vicar in 1984 through his driving of the the development of social enterprises, health centres and other vital services to this community – with the whole hearted support of the community and despite the best efforts of local and national Government.

I picked this book up almost by accident and I’m so glad that I did.  I found it incredibly motivating – whilst there are some good, practical hints in there it’s more of a history and how problems were coped with as they arose – I think the author should settle down and write a further book ‘Practical Lessons from Bromley-by-Bow’ – I would certainly buy a copy!

Rather than pontificate too much, I’ll refer you to an article by Andrew Mawson himself:

http://www.guardian.co.uk/society/2008/jan/09/socialenterprises.regeneration

I have to say that the experiences he documents reflect the sort of experiences I’ve had in a much smaller way with many funding organisations and local authority, national Government and EU bodies over the years.  This was the original impetus for my CommunityNet and CommunityHost projects, and reading this book has made me want bigger and better things for the projects that I’m involved with.

I agree with Mawson’s basic tenets; it is essential that anyone wishing to develop their community needs to get buy in from the bottom up – from the people who are suppsoed to benefit from the efforts being expended.  This means involving these people, and letting them become the architects of their own solutions – not watchers and observers.  This is the ‘CommunityNet Philosophy’ that I elaborate on here; I now feel in excellent company.

An excellent and motivational book; one that I whole heartedly recommend!

Will no one think about the children…

I’m a big fan of ‘The Simpsons’ and in one episode there is a morally outraged female character who keeps screaming the expression ‘Will no one think about the children’ whenever something crops up.

I was reminded of this sort of ineffective moral indignation when I encountered this article in The Sunday Times about the suggested censorship of sites such as Bebo, MySpace and acebook.

http://technology.timesonline.co.uk/tol/news/tech_and_web/article3635685.ece

Whilst I can see that there are posts and material that do require removing, I’m less convinced of the suggested ‘Remove within 24 hours of complaint’ approach.  A concerted effort by a few hardliners in some of our less liberal religious and social movements would soon have the websites removing all sorts of material.

Nothing is mentioned of appeal processes, etc. and as many of tehse sites are based in the US there is the US Constitutional Issue of Free Speech, as enshrined in the 1st Amendment.  The solution that I would adopt were I a US web site owner confronted by this sort of daft legislation from Nanny Brown’s Government would simply be to block access to the site form any UK based ISP.

And the comment about allowing children un-supervised use of the Internet not being like TV, but like letting your children play outside un-supervised is yet another issue.  When I was a child, from the age of about 10 onwards I WAS allowed to roam locally, in daylight, unsupervised.  Along with most other children of my generation.  However, I was responsible enough to have earned the trust of my parents.

Perhaps a major thing for HMG to take away from the curent fetish with protecting our children is that responsibility and supervision begins and should, under normal circumstances, end with the parents.  The state has no role unless things have gone very wrong; perhaps the fact that such studies are being commissioned indicates that several years of politically-correct nannying by this and previous Governments has generated a generation of parents who’re scared to actually be parents and state clearly to their children what is acceptable and what is unacceptable.

Reluctantly joining Facebook….

Sigh…..

That it should come to this.  Unfortunately a group I belong to is going to be using Facebook, and given that I’m supposed to be the IT guy, I am expected to know how it works.

So, I’ve registered and am working out how little I need to put up there whilst still making any use of it whatsoever.  I have to say that you won’t find much in the line of my social and business calendar up there – I cannot understand for the life of me why people publicise where they’re going to be and when they’re going to be there!

Or am I missing something?

People I know have started increasingly living their lives through bloody Facebook and so as these folks are fairly normal, well balanced individuals I assume that there must be something there that I’m not quite getting.  I’m not at all convinced that social networking sites are going to be with us for much longer, and I await to be convinced by my experiences on there.

Having said that, I just encountered this story on the BBC Website, which points to a future in terms of more local social networks.  Sort of like sites like Sheffield Forum or any other site of a similar nature that’s been around for 5 or 6 years.  There genuinely is nothing new under the sun…

So, poke away – I’m to be found here.

A great site – www.thisisawar.com

Earlier on today I was looking for the text of the ‘vision thing’ speech from the start of Jerry Maguire.  As to why I was looking for it – let’s just say I needed some motivation.  For those of you who’ve not encountered it, I include it here for your consideration.

And by some strange fluke I encountered, by accident, a site that is one of the most motivational and uplifting I’ve encountered for a very long time.  It’s great!  There’s some excelent stuff here – I intend having a very good read of it, and I heartily recommend it to you!

The site is called thisisawar.com.

Enjoy. 

The Bus Book – w/c 17th March – On Civil Disobedience

As the copy I have of ‘On Walden pond’ also includes this essay, it seemed churlish to not feature it here.

Thoreau spent a night in prison during his time at Walden, because he neglected to pay a local tax.  Whether he would have spent longer in prison than a single night had the tax not been paid isn’t clear, but as a local resident paid the tax, he was released.

The essay is an interesting diversion in to the rights and wrongs of civil disobedience, and is as relevant today as it was when it gave inspiration to anyone dealing with an unjust law over the intervening century and a half.  Thanks to people like Gandhi, the idea of civil disobedience as a valid and legitimate form of protest is something we take very much for granted today, but for Thoreau’s compatriots it must have been quite something.  Gandhi himself developed his techniques of passive resistance after reading this essay, and the comment “The Government that governs best, governs least’ is on the lips and in the heart of anyone who, like me, considers themselves to be a libertarian.

See here for an article on the essay, and here for an annotated text.

Thoreau’s issue with taxation was that he felt it was supporting the enslavement of his fellow man, through supporting a State legislature in favour of slavery.  He regarded not paying the relevant tax as a means by which anyone might raise a hand against the state; indeed, we need only look back to the ‘Poll Tax’ riots in the UK and the increasing numbers of people not paying that particular local charge non principle to see the impact.

It also set off a few thoughts for me; when I was younger I was much more willing to go to the wire on issues; now I’m older I’m less willing.  Thoreau was a single man, with little to lose, except his physical liberty.  Indeed, I get the impression from reading his essay that he would have happily handled a longer time in prison.  When you’re older, have a family and dependents, have a house, job, etc. it takes little imagination to see how a few months in jail could easily lead to loss of virtually everything you hold dear.  Perhaps one of the great accomplishments of the Consumerist State is that it gets people to behave more effectively than almost any other means thought of short of execution.

The times in my life when I have been willing to kick hard against the pricks, so to say, have been the time when the most has been taken from me and I was increasingly feeling cornered with little left to lose.  The balancing act between our consciences and what we’re willing to pay to be true to ourselves is what keeps us obedient slaves within our so called free society.

Reading this essay has made me think deeply about what is important and how far I am willing to go in my personal life to do what is right.  And it pains me to say that at the moment my courage, like that of many of us in contemporary society, is somewhat lacking.

Arthur C Clarke – RIP

Bugger.

Like a lot of things, I guess that in my heart of hearts I knew that eventually all the venerable old writers of science fiction, the folks who I grew up with, would all pass away.  When it starts happening it’s a strange experience.  The world has enough obituaries for ACC – here I just wanted to say something about what he means to me.

When ‘2001 – A Space Odyssey’ – came out I was a boy of 7 years old and although it played the local fleapit I didn’t see it.  I don’t remember whether I was too young to go, but I remember my mum wanting to see it.  I never found out whether she eventually got to see the movie or not; I only myself caught up with it after watching 2010, which is pretty arse-about-face.   In other words, I came to ACC not via his most famous work, but in my own way.

A British ‘boys weekly’ of the 1970s was called, I seem to remember, ‘Speed and Power’, and featured all sorts of machines, vehicles, etc. each week…aong with a short story from ACC.  And that’s where I encountered him first.  I still have a box of these magazines somewhere in the dark recesses of my attic, complete with the short stories which occupied many an evening, and encouraged me to go and find his other books.

The first ACC novel I read was ‘A Fall of Moondust’ – a disaster story about a ‘moon bus’ full of tourists that gets swamped in dust whilst traversing a lunar ‘sea’, and the efforts of rescuers to get them out.  The novel of his that made the biggest impact on me was ‘Rendezvous with Rama’ – I still remember the first time I read it, and even now it holds up.  Lovely, wonderful, story telling that I never get bored with.  I have to say that I’m very excited about the prospects of a film being made of the novel – possibly for release in 2009.  I’m keeping my fingers crossed!

But the short stories made the biggest impression on me.  As the years passed I just grabbed copeis of his collections of short stories from second hand shops, charity shops, wherever.  And of all of them, the ones that made the biggest and longest lasting impression were his ‘Tales from the White Hart’.   Quite why I have no idea – I guess that I just love ‘tallish tales’ that are just, maybe, plausible.  These stories, and those of Ray Bradbury and Stephen King, have probably been the major influences of my short story writing.  So much so that I’ve written a collection of similar stories – an ‘homage’, I guess – called ‘Tales from the Oakham Arms’.

I’m not even going to start on the technical innovations that ACC suggested, starting with his now famous Wireless World item on Geostationary Communication Satellites, that have now appeared in our lives.

Like someone else said recently, I really hope that as ACC passed away he was able to look deep into the cosmos and utter those final words of Dave Bowman’s…”My God, it’s full of stars”.

Thanks Sir Arthur.  My life would have been significantly poorer without your imagination.

Installing PEAR packages on WAMP

Well, after getting caught out recently with PEAR on a client installation, I thought it a good move to write a short tutorial for anyone who needs to install PEAR packages on their WAMP installation.

To start with, for the purposes of this blog, PEAR is a framework for implementing code libraries in PHP.  In other words, it prevents you from having to re-invent the wheel – always a nice thing!

Continue reading