| | |
How to establish alt text for datagrid headers?
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
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!
Has anyone successfully accomplished this with the Microsoft datagrid or a third party?
Thank you in advance!
•
•
Join Date: Jul 2007
Posts: 24
Reputation:
Solved Threads: 0
you should use javascript for this to achive for more information visit this website:
http://www.netomatix.com/GridToolTip.aspx
http://www.netomatix.com/GridToolTip.aspx
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.
In your aspx page you need to register a TagPrefix:
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.
ASP.NET Syntax (Toggle Plain Text)
using System; using System.Web.UI.WebControls; namespace yourproject.namespace { /// <summary> /// Summary description for wlBoundColumn. /// </summary> public class wlBoundColumn : BoundColumn { private string headerToolTip; public string HeaderToolTip { get{return headerToolTip;} set{headerToolTip = value;} } } /// <summary> /// Summary description for wlDataGrid. /// </summary> public class wlDataGrid : DataGrid { private const string HEADER_TOOLTIP_FORMAT = @"<p title=""{0}"">{1}</p>"; protected override void OnItemCreated(DataGridItemEventArgs e) { if(e.Item.ItemType == ListItemType.Header) { for (int i=0;i < e.Item.Cells.Count;i++) { if (Columns[i] is wlBoundColumn) { wlBoundColumn col = (wlBoundColumn)Columns[i]; if (col.HeaderToolTip != null) { TableCell cell = e.Item.Cells[i]; cell.Text = String.Format(HEADER_TOOLTIP_FORMAT, col.HeaderToolTip,cell.Text); } } } } //invoke base class method base.OnItemCreated(e); } } }
In your aspx page you need to register a TagPrefix:
aspnet Syntax (Toggle Plain Text)
<% @Page blah... %> <%@ Register TagPrefix="wlc" Namespace="yourproject.namespace" Assembly="yourprojectassemblyname" %> <DOCTYPE Blah ...> <html> <body> <form> <wlc:wlDataGrid id="wlDataGrid1" runat="server" AutoGenerateColumns="False"> <columns> <wlc:BoundColumn DataField="fieldname" HeaderText="header" HeaderToolTip="My header tooltip"></wlc:wlBoundColumn> </columns> </wlc:wlDataGrid> . . .
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.
![]() |
Similar Threads
- How to disable tab stop on datagrid headers? (ASP.NET)
- POpulate DataGrid (VB.NET)
- How to update a Datagrid cell in Javascript (C#)
- help with datagrid in vb.net (Visual Basic 4 / 5 / 6)
- Alt text for images (Web Browsers)
Other Threads in the ASP.NET Forum
- Previous Thread: question about required field validator
- Next Thread: aspnet_regsql - Shalvin aspnet
| Thread Tools | Search this Thread |
.net 3.5 ajax alltypeofvideos appliances asp asp.net bc30451 beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions control countryselector dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iis javascript list listbox login microsoft mouse mssql nameisnotdeclared news novell numerical opera panelmasterpagebuttoncontrols problem radio redirect registration relationaldatabases reportemail save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos vista visualstudio vs2008 web webapplications webdevelopemnt webdevelopment webprogramming webservice wizard xsl youareanotmemberofthedebuggerusers






