Highlighting DataGrid Rows on mouseOver

Discussion in 'ASP .Net' started by =?Utf-8?B?V2ViTWF0cml4?=, Dec 1, 2004.

  1. Hello,

    I need to extend functionality of ASP.NET datagrid. Onmouse over, the whole
    row needs to be highlighted. OnClick highlighted color must remain, and the
    value of one of the columns must be set to innerHTML property of a <div> tag
    (no postBack).
    Has anyone done anything like that?
     
    =?Utf-8?B?V2ViTWF0cml4?=, Dec 1, 2004
    #1
    1. Advertising

  2. Yep try using ItemCreated like below:-

    Sub MenuGrid_ItemCreated(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles MenuGrid.ItemCreated
    If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
    ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.SelectedItem
    Then
    e.Item.Attributes.Add("onmouseover",
    "this.style.backgroundColor='beige';this.style.cursor='hand'")
    e.Item.Attributes.Add("onmouseout",
    "this.style.backgroundColor='white';")
    End If
    End Sub

    Hope it helps!!
    Patrick



    "WebMatrix" wrote:

    > Hello,
    >
    > I need to extend functionality of ASP.NET datagrid. Onmouse over, the whole
    > row needs to be highlighted. OnClick highlighted color must remain, and the
    > value of one of the columns must be set to innerHTML property of a <div> tag
    > (no postBack).
    > Has anyone done anything like that?
     
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Dec 1, 2004
    #2
    1. Advertising

  3. Thanks for the prompt reply. I think yoiur code will work for highlighting.
    One more question; in this ItemCreated event, can I access a value of a
    specific column?
    Thank you!

    "Patrick.O.Ige" wrote:

    > Yep try using ItemCreated like below:-
    >
    > Sub MenuGrid_ItemCreated(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.DataGridItemEventArgs) Handles MenuGrid.ItemCreated
    > If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
    > ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.SelectedItem
    > Then
    > e.Item.Attributes.Add("onmouseover",
    > "this.style.backgroundColor='beige';this.style.cursor='hand'")
    > e.Item.Attributes.Add("onmouseout",
    > "this.style.backgroundColor='white';")
    > End If
    > End Sub
    >
    > Hope it helps!!
    > Patrick
    >
    >
    >
    > "WebMatrix" wrote:
    >
    > > Hello,
    > >
    > > I need to extend functionality of ASP.NET datagrid. Onmouse over, the whole
    > > row needs to be highlighted. OnClick highlighted color must remain, and the
    > > value of one of the columns must be set to innerHTML property of a <div> tag
    > > (no postBack).
    > > Has anyone done anything like that?
     
    =?Utf-8?B?V2ViTWF0cml4?=, Dec 1, 2004
    #3
  4. Yes WebMatrix..
    For example by doing (For the first Cell!!):-

    e.Item.Cells(1).Attributes.Add("onmouseover",
    "this.style.backgroundColor='#DDEEFF'")
    e.Item.Cells(1).Attributes.Add("onmouseout",
    "this.style.backgroundColor='white'")

    Enjoy
    Patrick



    "WebMatrix" wrote:

    > Thanks for the prompt reply. I think yoiur code will work for highlighting.
    > One more question; in this ItemCreated event, can I access a value of a
    > specific column?
    > Thank you!
    >
    > "Patrick.O.Ige" wrote:
    >
    > > Yep try using ItemCreated like below:-
    > >
    > > Sub MenuGrid_ItemCreated(ByVal sender As Object, ByVal e As
    > > System.Web.UI.WebControls.DataGridItemEventArgs) Handles MenuGrid.ItemCreated
    > > If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
    > > ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.SelectedItem
    > > Then
    > > e.Item.Attributes.Add("onmouseover",
    > > "this.style.backgroundColor='beige';this.style.cursor='hand'")
    > > e.Item.Attributes.Add("onmouseout",
    > > "this.style.backgroundColor='white';")
    > > End If
    > > End Sub
    > >
    > > Hope it helps!!
    > > Patrick
    > >
    > >
    > >
    > > "WebMatrix" wrote:
    > >
    > > > Hello,
    > > >
    > > > I need to extend functionality of ASP.NET datagrid. Onmouse over, the whole
    > > > row needs to be highlighted. OnClick highlighted color must remain, and the
    > > > value of one of the columns must be set to innerHTML property of a <div> tag
    > > > (no postBack).
    > > > Has anyone done anything like that?
     
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Dec 1, 2004
    #4
  5. If it is a bound column, the value will become known in ItemDataBound event.
    You can move all this code over there.

    Eliyahu

    "WebMatrix" <> wrote in message
    news:...
    > Thanks for the prompt reply. I think yoiur code will work for

    highlighting.
    > One more question; in this ItemCreated event, can I access a value of a
    > specific column?
    > Thank you!
    >
    > "Patrick.O.Ige" wrote:
    >
    > > Yep try using ItemCreated like below:-
    > >
    > > Sub MenuGrid_ItemCreated(ByVal sender As Object, ByVal e As
    > > System.Web.UI.WebControls.DataGridItemEventArgs) Handles

    MenuGrid.ItemCreated
    > > If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
    > > ListItemType.AlternatingItem Or e.Item.ItemType =

    ListItemType.SelectedItem
    > > Then
    > > e.Item.Attributes.Add("onmouseover",
    > > "this.style.backgroundColor='beige';this.style.cursor='hand'")
    > > e.Item.Attributes.Add("onmouseout",
    > > "this.style.backgroundColor='white';")
    > > End If
    > > End Sub
    > >
    > > Hope it helps!!
    > > Patrick
    > >
    > >
    > >
    > > "WebMatrix" wrote:
    > >
    > > > Hello,
    > > >
    > > > I need to extend functionality of ASP.NET datagrid. Onmouse over, the

    whole
    > > > row needs to be highlighted. OnClick highlighted color must remain,

    and the
    > > > value of one of the columns must be set to innerHTML property of a

    <div> tag
    > > > (no postBack).
    > > > Has anyone done anything like that?
     
    Eliyahu Goldin, Dec 1, 2004
    #5
    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. JohnSmith90
    Replies:
    7
    Views:
    2,277
    =?Utf-8?B?RWx0b24gVw==?=
    May 13, 2005
  2. Bob Loveshade
    Replies:
    1
    Views:
    7,683
    Venkat_KL
    Nov 19, 2005
  3. .NETn00b
    Replies:
    0
    Views:
    504
    .NETn00b
    Nov 19, 2005
  4. .NETn00b

    Selecting and Highlighting Multiple Rows in a DataGrid

    .NETn00b, Nov 19, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    129
    .NETn00b
    Nov 19, 2005
  5. Highlighting Rows

    , Jul 16, 2007, in forum: Javascript
    Replies:
    4
    Views:
    104
    David Mark
    Jul 16, 2007
Loading...

Share This Page