Override the Standard Status Bar Message of the DataGrid
page 2 of 5
by Steven Archibald
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 23403/ 86

The Solution

To add the code needed to override the default status messages, we make use of an ItemDataBound event handler of the DataGrid control. I presume it could also be done in the ItemDataCreated event handler, but I have become so accustomed to using the ItemDataBound event handler over the last few years that I never bothered to try the other event.

In the ItemDataBound event handler, we examine each ListItem created. For sort column headers, we must process the ListItemType of Header. For each ListItemType we are looking at, we must 'know' where the cells are that contain links. Actually, we could just loop through, looking at each control collection, but that's beyond the scope of this discussion. I assume, for pedagogical and practical purposes, that we know where they are. For my example, I'll only process the Header type, but the sample code listed below has a LinkButton in the Item and Alternating Item types, so you can play with that at your leisure.

Once we have a column with a link button, we must override the HTML attributes of the tag that will be created on render. It's important to remember, yet easy to forget, that ASP.NET ultimately renders a combination of HTML and JavaScript from the page and its code-behind. So, all we are ultimately going to do is control the HTML and JavaScript that gets produced.

View Entire Article

User Comments

Title: Solution to 'Unpreventable' standard behavior   
Name: Your Daddy
Date: 2007-01-04 12:30:26 PM
The javascript "onfocus" event for the anchor element can be used to get rid of that pesky status bar message that displays when you hold the left mouse button down. In addition to using onmouseover, onmousedown, onmouseup, onmouseout, etc, add an onfocus attribute to the anchor element.


Your Daddy
Title: self.status doesn't work in Firefox   
Name: slolife
Date: 2005-10-17 7:53:59 PM
self.status='Hello' doesn't work in Firefox. Is this a security/anti phishing thing?
Title: Mr   
Name: Abdul Salam
Date: 2005-10-12 12:23:38 AM
very good Thanks
Title: Link is always visible   
Name: kraftspl
Date: 2005-09-23 6:45:18 PM
Nice work, but the referenced link is always visible in the status bar, when you click a link. You will furthermore see a status message.

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-29 7:31:57 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search