attributes to ListItemType.Header

Discussion in 'ASP .Net Datagrid Control' started by hansiman, Sep 17, 2004.

  1. hansiman

    hansiman Guest

    I want to add tooltexttips to a datagrids column headers. The code
    below handles BoundColumn but not TemplateColumn - and I can't figure
    out how to have it handle both.

    ' add tooltip text to selected header column cells
    Private Sub dg_ItemCreated( _
    ByVal sender As Object,
    ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
    Handles dgSkema2a.ItemCreated

    If e.Item.ItemType = ListItemType.Header Then
    Dim idx As Integer = 0
    Dim cl As TableCell
    For Each cl In e.Item.Cells
    If InStr(cl.Text, "HR") > 0 Then
    With cl
    .ToolTip = GetToolTip(idx)
    .Attributes.Add("style", "cursor:help;")
    End With
    End If
    idx += 1
    Next
    End If
    End Sub

    /Morten
     
    hansiman, Sep 17, 2004
    #1
    1. Advertising

  2. hansiman

    hansiman Guest

    Forgot to mention that I only want specific columns to have the
    attributes: instr(cl.text, "HR") > 0

    ....and here lies the problem.
    cl.Text of a BoundColumn returns column header text
    cl.Text of a TemplateColumn returns ""

    I can't find the correct property!!!


    On Fri, 17 Sep 2004 16:46:10 +0200, hansiman <>
    wrote:

    >I want to add tooltexttips to a datagrids column headers. The code
    >below handles BoundColumn but not TemplateColumn - and I can't figure
    >out how to have it handle both.
    >
    > ' add tooltip text to selected header column cells
    > Private Sub dg_ItemCreated( _
    > ByVal sender As Object,
    > ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
    > Handles dgSkema2a.ItemCreated
    >
    > If e.Item.ItemType = ListItemType.Header Then
    > Dim idx As Integer = 0
    > Dim cl As TableCell
    > For Each cl In e.Item.Cells
    > If InStr(cl.Text, "HR") > 0 Then
    > With cl
    > .ToolTip = GetToolTip(idx)
    > .Attributes.Add("style", "cursor:help;")
    > End With
    > End If
    > idx += 1
    > Next
    > End If
    > End Sub
    >
    >/Morten
     
    hansiman, Sep 17, 2004
    #2
    1. Advertising

  3. Try doing this in PreRender event.

    Eliyahu

    "hansiman" <> wrote in message
    news:...
    > I want to add tooltexttips to a datagrids column headers. The code
    > below handles BoundColumn but not TemplateColumn - and I can't figure
    > out how to have it handle both.
    >
    > ' add tooltip text to selected header column cells
    > Private Sub dg_ItemCreated( _
    > ByVal sender As Object,
    > ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
    > Handles dgSkema2a.ItemCreated
    >
    > If e.Item.ItemType = ListItemType.Header Then
    > Dim idx As Integer = 0
    > Dim cl As TableCell
    > For Each cl In e.Item.Cells
    > If InStr(cl.Text, "HR") > 0 Then
    > With cl
    > .ToolTip = GetToolTip(idx)
    > .Attributes.Add("style", "cursor:help;")
    > End With
    > End If
    > idx += 1
    > Next
    > End If
    > End Sub
    >
    > /Morten
    >
     
    Eliyahu Goldin, Sep 19, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Max
    Replies:
    1
    Views:
    484
    Joe Kesselman
    Sep 22, 2006
  2. P4trykx
    Replies:
    2
    Views:
    1,827
    bruce barker
    Jan 31, 2007
  3. james_027

    class attributes & data attributes

    james_027, Jun 20, 2007, in forum: Python
    Replies:
    2
    Views:
    377
    Bruno Desthuilliers
    Jun 20, 2007
  4. mlt
    Replies:
    2
    Views:
    853
    Jean-Marc Bourguet
    Jan 31, 2009
  5. Kyle Schmitt
    Replies:
    3
    Views:
    194
    Kyle Schmitt
    Jul 24, 2007
Loading...

Share This Page