By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,710 Members | 1,613 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,710 IT Pros & Developers. It's quick & easy.

setting focus to datagrid item

P: 41
I have a datagrid in ASP.NET using VB.NET code which, when loaded it takes a parameter from the URL called DexNumb. When this parameter is brought it, it highlights the entire row Red and makes it bold but if the datagrid is long and some elements can only be viewed by scrolling down, it will not go straight to the elements, the user must scroll down in order to view them. Here is the method that is launched from the datagrid on Page_Load:
Expand|Select|Wrap|Line Numbers
  1.           Protected Sub PopulateIPC_OnItemDataBound(ByVal sender as System.Object, ByVal e As DataGridItemEventArgs) Handles PopulateIPC.ItemDataBound
  2.       Dim JScrpt As String    
  3.        If e.Item.Cells(0).Text = DexNumb Then
  4.           e.Item.BackColor = System.Drawing.Color.Red
  5.           e.Item.Font.Bold=True
  6.              JScrpt = "<script language=JavaScript>"
  7.                         JScrpt += "e.Item.Cells.focus();"
  8.                         JScrpt += "<"
  9.                         JScrpt += "/script>"
  10.                         Page.RegisterStartupScript("Popup", JScrpt)
  11.        End If
  12.      End Sub 

The Javascript is contained in the method but it works the same way with or without it. Any thoughts on a quick fix for this? TIA
Feb 28 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.