Gridview tab order

Posted on 2007-10-16
Last Modified: 2009-12-16
I found Gridview tab order works only with a dataset/table datasource and not with an objectdatasource. I have been pulling my hair over this for days. 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's the 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?
    LVL 18

    Expert Comment

    by:Ajay Sharma
    use   e.Item.Cells(0).Controls(0).TabIndex = CInt(Session("tabs")) + 1

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    794 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

    18 Experts available now in Live!

    Get 1:1 Help Now