con.Open()
        cmd.Connection = con
        dataGrid.SelectedIndex = dataGrid.CurrentItem(0)
        MessageBox.Show("User Has Selected " & dataGrid.SelectedIndex)
        Dim id As Integer = dataGrid.SelectedIndex(0).cells("Appid").value.ToString()
        Dim fname As String = dataGrid.SelectedRows(0).cells("Fname").value.ToString()
        Dim mname As String = dataGrid.SelectedRows(0).cells("Mname").value.ToString()
        Dim lname As String = dataGrid.SelectedRows(0).cells("Lname").value.ToString()
        Dim fthname As String = dataGrid.SelectedRows(0).cells("Fthname").value.ToString()
        Dim mthname As String = dataGrid.SelectedRows(0).cells("Mthname").value.ToString()
        Dim occp As String = dataGrid.SelectedRows(0).cells("Occupation").value.ToString()
        Dim dob As Date = dataGrid.SelectedRows(0).cells("DOB").value.ToString()
        Dim mbno As String = dataGrid.SelectedRows(0).cells("Mbno").value.ToString()
        Dim emid As String = dataGrid.SelectedRows(0).cells("Emailid").value.ToString()
        Dim addr As String = dataGrid.SelectedRows(0).cells("Address").value.ToString()
        Dim nat As String = dataGrid.SelectedRows(0).cells("Nationality").value.ToString()
            This is the Message Box that should contains the fields of the selected row, but it gives the error on datagrid.selectedRows(0).cells("Mbno").value.ToString()
            MessageBox.Show(id & "," & fname & "," & mname & "," & lname & "," & fthname & "," & mthname & "," & occp & "," & dob & "," & mbno & "," & emid & "," & addr & "," & nat)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.