I'm using several datagrids where the user can select the row by clicking
anywhere on that row. I'd like to be able to show the hand cursor when
mousing over databound rows. Does anyone know how to do this?

Will

Reply to this message...
 
    
Cooke, Derek
Will

You can use the cursor property of the style object in DHTML. You will need
to code something like the following server side to add the required client
side attribute.

myRow.attributes.add("onmouseover","this.style.cursor='hand'")

Which will produce HTML on the client as below
<TR onmouseover="this.style.cursor='hand'">

Derek

-----Original Message-----
From: Will Currie [mailto:Click here to reveal e-mail address]
Sent: 13 May 2002 08:06
To: aspngclient
Subject: [aspngclient] onmouseOver row in datagrid

-- Copied from [aspngdatagridrepeaterdatalist] to [aspngclient] by Marcie
Jones <Click here to reveal e-mail address> --

I'm using several datagrids where the user can select the row by clicking
anywhere on that row. I'd like to be able to show the hand cursor when
mousing over databound rows. Does anyone know how to do this?

Will
| [aspngclient] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngclient.asp = JOIN/QUIT

=======================================================================
Information in this email and any attachments are confidential, and may
not be copied or used by anyone other than the addressee, nor disclosed
to any third party without our permission. There is no intention to
create any legally binding contract or other commitment through the use
of this email.

Experian Limited (registration number 653331).
Registered office: Talbot House, Talbot Street, Nottingham NG1 5HF

Reply to this message...
 
    
Matt Serdar
I've stayed away from datagrid's for this very reason. I use repeaters
instead and add mouse events to my <tr> tags that get wrapped inside
<itemtemplate> tags.
So, it would look something like this.

<itemtemplate>
<tr onmouseover="javascript:this.style.backgroundColor='#FFFFCC';
this.style.cursor='hand'; return true;"
onmouseout="javascript:this.style.backgroundColor='';
this.style.cursor='default';this.style.backgroundColor=''; return true;">
<td style="padding-left: 7px"><nobr><%# Container.DataItem("PersonLastName")
%></nobr></td>
</tr>
</itemtemplate>

hth

matt

-----Original Message-----
From: Will Currie [mailto:Click here to reveal e-mail address]
Sent: Monday, May 13, 2002 12:06 AM
To: aspngclient
Subject: [aspngclient] onmouseOver row in datagrid

-- Copied from [aspngdatagridrepeaterdatalist] to [aspngclient] by Marcie
Jones <Click here to reveal e-mail address> --

I'm using several datagrids where the user can select the row by clicking
anywhere on that row. I'd like to be able to show the hand cursor when
mousing over databound rows. Does anyone know how to do this?

Will
| [aspngclient] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngclient.asp = JOIN/QUIT

Reply to this message...
 
    
Will Currie
This is working fine for me in the DataGrid

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound

Dim itemType As ListItemType = e.Item.ItemType
If ((itemType = ListItemType.Pager) Or (itemType = ListItemType.Header)
Or (itemType = ListItemType.Footer)) Then
Return
Else
Dim button As LinkButton = CType(e.Item.Cells(1).Controls(0),
LinkButton)
e.Item.Attributes("onclick") = Page.GetPostBackClientHyperlink(button,
"")
e.Item.Attributes.Add("OnMouseOver",
"this.style.cursor='hand';this.className='altRow';")
e.Item.Attributes.Add("OnMouseOut", "this.className='linkRow';")
End If
End Sub

It enables the row to be selected by clicking anywhere on it and also does
the mouseover stuff too.

Will

-----Original Message-----
From: Matt Serdar [mailto:Click here to reveal e-mail address]
Sent: 13 May 2002 14:58
To: aspngclient
Subject: [aspngclient] RE: onmouseOver row in datagrid

I've stayed away from datagrid's for this very reason. I use repeaters
instead and add mouse events to my <tr> tags that get wrapped inside
<itemtemplate> tags.
So, it would look something like this.

<itemtemplate>
<tr onmouseover="javascript:this.style.backgroundColor='#FFFFCC';
this.style.cursor='hand'; return true;"
onmouseout="javascript:this.style.backgroundColor='';
this.style.cursor='default';this.style.backgroundColor=''; return true;">
<td style="padding-left: 7px"><nobr><%# Container.DataItem("PersonLastName")
%></nobr></td>
</tr>
</itemtemplate>

hth

matt

-----Original Message-----
From: Will Currie [mailto:Click here to reveal e-mail address]
Sent: Monday, May 13, 2002 12:06 AM
To: aspngclient
Subject: [aspngclient] onmouseOver row in datagrid

-- Copied from [aspngdatagridrepeaterdatalist] to [aspngclient] by Marcie
Jones <Click here to reveal e-mail address> --

I'm using several datagrids where the user can select the row by clicking
anywhere on that row. I'd like to be able to show the hand cursor when
mousing over databound rows. Does anyone know how to do this?

Will
| [aspngclient] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngclient.asp = JOIN/QUIT

| [aspngclient] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngclient.asp = JOIN/QUIT

Reply to this message...
 
    
Matt Serdar
That looks really good Will.
Is the LinkButton required just for the onclick event? Does it basically
make the entire row clickable?

matt

-----Original Message-----
From: Will Currie [mailto:Click here to reveal e-mail address]
Sent: Monday, May 13, 2002 8:04 AM
To: aspngclient
Subject: [aspngclient] RE: onmouseOver row in datagrid

This is working fine for me in the DataGrid

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound

Dim itemType As ListItemType = e.Item.ItemType
If ((itemType = ListItemType.Pager) Or (itemType = ListItemType.Header)
Or (itemType = ListItemType.Footer)) Then
Return
Else
Dim button As LinkButton = CType(e.Item.Cells(1).Controls(0),
LinkButton)
e.Item.Attributes("onclick") = Page.GetPostBackClientHyperlink(button,
"")
e.Item.Attributes.Add("OnMouseOver",
"this.style.cursor='hand';this.className='altRow';")
e.Item.Attributes.Add("OnMouseOut", "this.className='linkRow';")
End If
End Sub

It enables the row to be selected by clicking anywhere on it and also does
the mouseover stuff too.

Will

Reply to this message...
 
    
Will Currie
Yes this makes the entire row clickable/selectable.
The link button exists in column 1 of the DG but its visibility is set to
false. The only column I have visible is a template column with some fancy
DHTML in it. This solution works fine even in the template column. The
mouseover hand gives the user better feedback.

-----Original Message-----
From: Matt Serdar [mailto:Click here to reveal e-mail address]
Sent: 13 May 2002 17:47
To: aspngclient
Subject: [aspngclient] RE: onmouseOver row in datagrid

That looks really good Will.
Is the LinkButton required just for the onclick event? Does it basically
make the entire row clickable?

matt

-----Original Message-----
From: Will Currie [mailto:Click here to reveal e-mail address]
Sent: Monday, May 13, 2002 8:04 AM
To: aspngclient
Subject: [aspngclient] RE: onmouseOver row in datagrid

This is working fine for me in the DataGrid

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound

Dim itemType As ListItemType = e.Item.ItemType
If ((itemType = ListItemType.Pager) Or (itemType = ListItemType.Header)
Or (itemType = ListItemType.Footer)) Then
Return
Else
Dim button As LinkButton = CType(e.Item.Cells(1).Controls(0),
LinkButton)
e.Item.Attributes("onclick") = Page.GetPostBackClientHyperlink(button,
"")
e.Item.Attributes.Add("OnMouseOver",
"this.style.cursor='hand';this.className='altRow';")
e.Item.Attributes.Add("OnMouseOut", "this.className='linkRow';")
End If
End Sub

It enables the row to be selected by clicking anywhere on it and also does
the mouseover stuff too.

Will