window.status messages for sort and hyperlink columns

M

Michael Hetrick

I would like to have a friendly status message onMouseOver of sort columns
in the datagrid. Instead of the standard "javascript:__doPostBack...", I
would like to have status bar show "Sort By [ColumnName]".

Likewise, I would like to be able to have status messages based on row for
the grid's HyperlinkColumn as in "View Details for [Item]".

How would I go about doing this? Thanks in advance...


Michael
 
Y

Yan-Hong Huang[MSFT]

Hello Michael,

If we want to manipulate controls in a DataGrid, we need to intercept the ItemCreated or ItemDataBound event of the
DataGrid, e.g.

DataGrid1.ItemCreated += new DataGridItemEventHandler(ItemCreatedHandler);

Now you get a call to your function (here: ItemCreatedHandler) for every item of the DataGrid. You have to filter for the item(s)
you want to add your javascript code to. For an example:

Private Sub MyDataGrid_ItemCreated _
(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles MyDataGrid.ItemCreated
Dim dgItem As DataGridItem
dgItem = e.Item
If dgItem.ItemType = ListItemType.AlternatingItem _
Or dgItem.ItemType = ListItemType.Item Then
dgItem.Attributes.Add("onmouseover", _
"window.status='select article Xx';")
End If
End Sub

Hope this helps

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "Michael Hetrick" <[email protected]>
!Subject: window.status messages for sort and hyperlink columns
!Date: Tue, 22 Jul 2003 19:42:23 -0400
!Lines: 13
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <[email protected]>
!Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
!NNTP-Posting-Host: ip68-100-126-71.nv.nv.cox.net 68.100.126.71
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.datagridcontrol:5816
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
!
!I would like to have a friendly status message onMouseOver of sort columns
!in the datagrid. Instead of the standard "javascript:__doPostBack...", I
!would like to have status bar show "Sort By [ColumnName]".
!
!Likewise, I would like to be able to have status messages based on row for
!the grid's HyperlinkColumn as in "View Details for [Item]".
!
!How would I go about doing this? Thanks in advance...
!
!
!Michael
!
!
!
 
M

Michael Hetrick

Thanks! That got me off to a good start. I've switched to tooltips instead
of window.status. I have some questions about how to get the text in a
datagrid cell - specifically in the else if block below:

private void DataGrid1_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{
//Text works because there is a link button in the header
((LinkButton)e.Item.Cells[1].Controls[0]).ToolTip = "Sort by " +
((LinkButton)e.Item.Cells[2].Controls[0]).Text;
}
else if ((e.Item.ItemType == ListItemType.AlternatingItem) ||
(e.Item.ItemType == ListItemType.Item))
{
//How do I find the text in a HyperLink column? I want the link
text to appear where I put the ??? below:
((HyperLink)e.Item.Cells[1].Controls[0]).ToolTip = "View Details for
" + ???;
}
}

In the if block, I can get the cell text from the link button's text
property, but the accessing the cell text from the HyperLink column just
isn't working. Thanks in advance.

Michael


Yan-Hong Huang said:
Hello Michael,

If we want to manipulate controls in a DataGrid, we need to intercept the
ItemCreated or ItemDataBound event of the
DataGrid, e.g.

DataGrid1.ItemCreated += new DataGridItemEventHandler(ItemCreatedHandler);

Now you get a call to your function (here: ItemCreatedHandler) for every
item of the DataGrid. You have to filter for the item(s)
you want to add your javascript code to. For an example:

Private Sub MyDataGrid_ItemCreated _
(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles MyDataGrid.ItemCreated
Dim dgItem As DataGridItem
dgItem = e.Item
If dgItem.ItemType = ListItemType.AlternatingItem _
Or dgItem.ItemType = ListItemType.Item Then
dgItem.Attributes.Add("onmouseover", _
"window.status='select article Xx';")
End If
End Sub

Hope this helps

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "Michael Hetrick" <[email protected]>
!Subject: window.status messages for sort and hyperlink columns
!Date: Tue, 22 Jul 2003 19:42:23 -0400
!Lines: 13
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <[email protected]>
!Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
!NNTP-Posting-Host: ip68-100-126-71.nv.nv.cox.net 68.100.126.71
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.datagridcontrol:5816
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
!
!I would like to have a friendly status message onMouseOver of sort columns
!in the datagrid. Instead of the standard "javascript:__doPostBack...", I
!would like to have status bar show "Sort By [ColumnName]".
!
!Likewise, I would like to be able to have status messages based on row for
!the grid's HyperlinkColumn as in "View Details for [Item]".
!
!How would I go about doing this? Thanks in advance...
!
!
!Michael
!
!
!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top