Add tooptip/title to a sortable gridview header


Find the linkbuttons from the header row and assign the text to them throgh OnRowDataBound event.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
          
            foreach (System.Web.UI.WebControls.TableCell cell in e.Row.Cells)
            {
                foreach (Control ctl in cell.Controls)
                {
                    LinkButton link = ctl as LinkButton;
                    if (link != null)
                    {
                       link.ToolTip="By clicking here you will sort this column ";
                    }
                   
                }
            }
        }
    }
Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s