Hi Richard,
I think this will do what you want.
**** Panel and grid
<asp
anel id="Panel1" runat="server" Height="100px" style="OVERFLOW: auto">
<asp
ataGrid id="DataGrid1" runat="server">
<Columns>
<asp:ButtonColumn Text="Select"
CommandName="Select"></asp:ButtonColumn>
</Columns>
</asp
ataGrid>
</asp
anel>
**** Code
Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged
Dim s As String = "<script language='javascript'>
document.all('DataGrid1_tr_" & DataGrid1.SelectedIndex &
"').scrollIntoView(); </script>"
RegisterStartupScript("DataGrid1_SelectedIndexChanged", s)
End Sub
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
Dim tr As DataGridItem
tr = e.Item
tr.Attributes.Add("id", "DataGrid1_tr_" & e.Item.ItemIndex)
End Sub
Does this answer your question?
Thank you, Mike
Microsoft, ASP.NET Support Professional
Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer's security.
This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
From: "Richard Loupatty" <
[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Subject: Visibility of selectedindex of a datagriditem
Date: Mon, 12 Jan 2004 11:30:56 +0100
Organization: MIO Development bv
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.0
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Lines: 15
Message-ID: <
[email protected]>
NNTP-Posting-Date: 12 Jan 2004 10:31:01 GMT
NNTP-Posting-Host: unlabelled-95-38-59-62.versatel.net
X-Trace: 1073903461 news.versatel.net 37823 62.59.38.95:64443
X-Complaints-To: (e-mail address removed)
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news-fra1.dfn.de!news2.telebyte.nl!news.cambrium.nl!news.cambrium.nl!news.cambrium.nl!news2.euro.net!beastial
ity.euro.net!postnews1.euro.net!news.versatel.net!not-for-mail
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:201370
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
I put a datagrid in a panel with an overflow set on auto.
I want to show just 5 items in the grid.
My question is how to make sure that the selecteditem is always visible in
the grid. Because now i have this situation that after each selection (I use
the itemcommand) the grid starts from the top.
when i (for example) set selectedindex = 8, the selection is made, but not
visible to me. I have to scroll down first.
tia
Richard Loupatty