ASP 101 - Active Server Pages 101 - Web01
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates

ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

ASP.NET "Database Highlight" Sample

When I started trying to implement last week's database row highlighting sample in ASP.NET, I naturally looked for a simple and elegant solution. When I was unable to come up with one easily on my own, I went to the web. Surely someone had done this before. The answer was bound to be out there just waiting for me to find it. Well I found plenty of answers, but none of them were very simple, let alone elegant.

The best of what I found came from the place I usually end up finding the best stuff... 4GuysFromRolla. Both Creating a Row-Selectable DataGrid Control and An Easier Way to Highlight the Rows of a DataGrid on MouseOver address the issue at hand and actually do a pretty good job. The problem is that the first is relatively complicated (it creates a new custom control which inherits from the DataGrid to get the job done) and the second has some compatibility issues (which stem from the author's desire to use CSS even though the lack of support for it forces him to use JavaScript to back it up anyway). While the solutions presented in those articles are probably technically "better" then my approach (the reusability and added functionality of the custom control in particular are big benefits), I wanted something simple (I'd long since given up on any level of elegance).

So here it is... the secret to getting simple database row highlighting in ASP.NET -- don't use the DataGrid! Instead of trying to wrangle the JavaScript into the table that the DataGrid generates, I just used the Repeater instead and built my own table. It may not be the coolest or most exciting approach (and we already know it's not the most elegant), but it's pretty darn simple. Just take a look at the code...

Here's a zip file of the code (1 KB).

Play with the running version.

View the live source code.

Back to the "Database Highlight" sample


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers