|
using System;
using System.Web.UI.WebControls;
namespace samplewebapp
{
public class CustomDataGrid : DataGrid
{
private const string HEADER_TOOLTIP_FORMAT = @"<p title=""{0}"">{1}</p>";
/// <summary>
/// Adds tooltip capability to column headers
/// </summary>
/// <param name="e">DataGridItemEventArgs</param>
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 CustomBoundColumn)
{
CustomBoundColumn col = (CustomBoundColumn)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);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.