• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2680
  • Last Modified:

Gridview tab index not working right

I hope someone can help with this case. I have a gridview whose datasource is an objectdatasource. When the user tabs across the gridview, the tab order goes vertically thru the cells from one column to the next instead of going horizontally across each row. Please advise. Thanks.
  • 2
1 Solution
Ajay SharmaCommented:
u can do it in the itemDataBound event of dataview

first take a session variable so that u can retrive and set value anywhere.
in page load
      Session("tabs") = 0

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

        e.Item.Cells(0).TabIndex = CInt(Session("tabs")) + 1
        e.Item.Cells(1).TabIndex = CInt(Session("tabs")) + 2
        e.Item.Cells(2).TabIndex = CInt(Session("tabs")) + 3
        Session("tabs") = CInt(Session("tabs")) + 3

End Sub

so this would be called on every data row created in dataview and every column will be got its Tabindex.

just replace e.Item.Cells(0).TabIndex with e.Item.Cells(0).controles(0).TabIndex if u have  a control in the column.
ksfokAuthor Commented:
What is the equivalent of ItemDataBound event for a gridview?
ksfokAuthor Commented:
Now I have made the tabbing work. But when the cell is tabbed to, the focus is set on the cell and not on the textbox inside. I have to manually place the mouse over the cell to set focus on the textbox. How can the focus be set on the textbox when the tab reaches the cell?

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now