How can I access the selected row value in datagrid in .vb.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sep410
    New Member
    • Jul 2008
    • 77

    How can I access the selected row value in datagrid in .vb.net

    Hi,
    How can I access the selected row value in datagrid in vb.net?
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Well first, lets establish which object you are using.
    DataGrid(should be avoided)
    DataGridView(pr efered)
    GridView(Web only)

    Comment

    • Sep410
      New Member
      • Jul 2008
      • 77

      #3
      I am using datagrid because I need to have child and parent grid.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        I wasn't aware the others didn't do it. But whatever.
        DataGrid's have a .CurrentCell that will give you the selected cell, which contains the row number and the column number. You can use the row number to access everything in the selected row from your datasource.

        Comment

        • Sep410
          New Member
          • Jul 2008
          • 77

          #5
          Can you explain more because I don't think I can have access to selected row value. I don't know where to use this selected row index.

          datagrid does not know this:

          MyDataGrid.Row( MyDataGrid.curr entRowIndex).ce ll()...

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            If you have the RowIndex, just go to that row in your datasource and examine the row's contents.
            Should not be hard.

            Comment

            • Sep410
              New Member
              • Jul 2008
              • 77

              #7
              Thanks.
              I used datagrid datasource and it is working.

              Comment

              Working...