Saturday, January 17, 2009

Applying Styles on EditCommandColumn buttons

Every button looked good. I mean, according to the project standards. Every button had that blue gradient background, with bold text. Every button looked good. Except that of the datagrid's EditCommandColumns and ButtonColumns.

Mmmhh... intelligent me, I immediately got down to work and applied the stylesheet property (CssClass, that is) to each buttons on ItemDataBound event of the datagrid.

Neh, it wouldn't budge.

Ha! It could be ItemCreated.... yeah, that is it. ItemCreated. How foolish I could be? Did I forget all those days when I had these memorized in my smart brain?

Select. Copy. Paste.

ItemDataBound event handler replaced with ItemCreated event handler. It should work this time. It should!

What? It doesn't? Why? The code says to apply the stylesheet every time the row is being created. Why not?

Mmmhhh... what should be the next step?

Google!

I was right, even the most reputed forums support that I was right!

What might have happened?

I had to find out. Right-Click. View Source.

Mmmhh.... see... every button in the EditCommandColumn and ButtonColumn had the "class=" already applied... for Edit button, it was "Button_Edit", for update button, it was "Button_Update"... and so on...

And it wouldn't change even if I insist.

Open Style.css. Create a new class for Button_Edit, Button_Update... and so on.

Eureka!!

That gradient blue background.... in my EditCommandColumn buttons too...

No comments:

Post a Comment

Cookies, anyone?

  Our application started having integration issues early March this year. Did I say that was intermittent? To add to our confusion, we coul...