943,742 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 2703
  • ASP.NET RSS
Jul 31st, 2007
0

How to establish alt text for datagrid headers?

Expand Post »
Hello, I am working in VS.NET 2003 with the original datagrid control. There does not appear to be a published technique for displaying alt text on the grid headers (e.g. mouseover causes a pop-up explaining what the column represents).

Has anyone successfully accomplished this with the Microsoft datagrid or a third party?

Thank you in advance!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kingflux is offline Offline
12 posts
since Sep 2006
Aug 1st, 2007
0

Re: How to establish alt text for datagrid headers?

you should use javascript for this to achive for more information visit this website:
http://www.netomatix.com/GridToolTip.aspx
Reputation Points: 10
Solved Threads: 0
Newbie Poster
atal is offline Offline
24 posts
since Jul 2007
Aug 2nd, 2007
0

Re: How to establish alt text for datagrid headers?

For IE, I think setting the title attribute will do that. I'm pretty sure that this does not work on Firefox however.
Reputation Points: 683
Solved Threads: 53
Posting Virtuoso
Infarction is offline Offline
1,580 posts
since May 2006
Aug 2nd, 2007
0

Re: How to establish alt text for datagrid headers?

Inherit from BoundColumn and DataGrid classes. Add a public string accessor for the tool tip text in the BoundColumn derived class. Override the OnItemCreated event in your derived DataGrid class. My company is Weblogik so we prefix all our derived classes wl, so you might want to change that.

ASP.NET Syntax (Toggle Plain Text)
  1. using System;
  2. using System.Web.UI.WebControls;
  3.  
  4. namespace yourproject.namespace
  5. {
  6. /// <summary>
  7. /// Summary description for wlBoundColumn.
  8. /// </summary>
  9. public class wlBoundColumn : BoundColumn
  10. {
  11. private string headerToolTip;
  12. public string HeaderToolTip
  13. {
  14. get{return headerToolTip;}
  15. set{headerToolTip = value;}
  16. }
  17. }
  18.  
  19. /// <summary>
  20. /// Summary description for wlDataGrid.
  21. /// </summary>
  22. public class wlDataGrid : DataGrid
  23. {
  24. private const string HEADER_TOOLTIP_FORMAT = @"<p title=""{0}"">{1}</p>";
  25.  
  26. protected override void OnItemCreated(DataGridItemEventArgs e)
  27. {
  28. if(e.Item.ItemType == ListItemType.Header)
  29. {
  30. for (int i=0;i < e.Item.Cells.Count;i++)
  31. {
  32. if (Columns[i] is wlBoundColumn)
  33. {
  34. wlBoundColumn col = (wlBoundColumn)Columns[i];
  35. if (col.HeaderToolTip != null)
  36. {
  37. TableCell cell = e.Item.Cells[i]; cell.Text = String.Format(HEADER_TOOLTIP_FORMAT,
  38. col.HeaderToolTip,cell.Text);
  39. }
  40. }
  41. }
  42. }
  43. //invoke base class method
  44. base.OnItemCreated(e);
  45. }
  46. }
  47. }

In your aspx page you need to register a TagPrefix:

aspnet Syntax (Toggle Plain Text)
  1. <% @Page blah... %>
  2. <%@ Register TagPrefix="wlc" Namespace="yourproject.namespace" Assembly="yourprojectassemblyname" %>
  3.  
  4. <DOCTYPE Blah ...>
  5.  
  6. <html>
  7. <body>
  8. <form>
  9.  
  10. <wlc:wlDataGrid id="wlDataGrid1" runat="server" AutoGenerateColumns="False">
  11. <columns>
  12. <wlc:BoundColumn DataField="fieldname" HeaderText="header" HeaderToolTip="My header tooltip"></wlc:wlBoundColumn>
  13. </columns>
  14. </wlc:wlDataGrid>
  15.  
  16. .
  17. .
  18. .

I have found this works in FireFox (1.5 tested, I haven't tried 2.0), but there seems a strange behaviour, if you 'view page source' it stops working properly afterwards. I don't know if that has anything to do with the page being in a pop-up child window.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
Mar 3rd, 2008
0

Re: How to establish alt text for datagrid headers?

Hello, Infarction-- There is no title attribute in the DataGrid control. I've checked .NET 1.1, 2.0, and 3.5.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kingflux is offline Offline
12 posts
since Sep 2006
Mar 3rd, 2008
0

Re: How to establish alt text for datagrid headers?

Hello, Paul-- I'm finally getting to this. The derived class compiles without errors, I added a line the aspx to register the new TagPrefix, but now I get The directive is missing a 'src' attribute.

Any ideas?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kingflux is offline Offline
12 posts
since Sep 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: question about required field validator
Next Thread in ASP.NET Forum Timeline: aspnet_regsql - Shalvin aspnet





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC