Gridview tab index not working right

Posted on 2007-10-16
Last Modified: 2008-01-09
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.
Question by:ksfok
    LVL 18

    Accepted Solution

    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.

    Author Comment

    What is the equivalent of ItemDataBound event for a gridview?

    Author Comment

    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

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now