How to create a link in a a gridview where when its clicked data is displayed in 8 text boxes RRS feed

  • Question

  • So far I have imported data in from microsoft Access table and displayed it in a gridview. The data that I want in the text boxes I have displayed on the source Page for now but I want it in the textboxes but am unsure how to go about this. I am looking to turn the first column of the gridview into a link that displayed the data from row 17-24 in 8 textboxes.(17 in textbox1, 18 in textbox2 etc). I am new to vb.net so am not very familar with this type of coding. any help would be much apprciated.

    The code I have so far:

    Imports System.Data
    Imports System.Data.OleDb
    Partial Class _Default
        Inherits System.Web.UI.Page
        Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim conConn As OleDbConnection = Nothing
            Dim comComm As OleDbCommand = Nothing
            Dim adpAdap As OleDbDataAdapter = Nothing
            Dim strOleCon As String = Nothing
            Dim DataTbl As New DataSet
                strOleCon = "Provider= Microsoft.ACE.OLEDB.12.0;Data Source='FilePath'; Persist Security Info=False;"
                conConn = New OleDbConnection(strOleCon)
                comComm = New OleDbCommand
                With comComm
                    .Connection = conConn
                    .CommandType = CommandType.Text
                    .CommandText = "SELECT * FROM AcessFileName WHERE (Tax = @Tax)"
                    .Parameters.AddWithValue("@Tax", TextBox1.Text)
                End With
                adpAdap = New OleDbDataAdapter(comComm)
                adpAdap.Fill(DataTbl, "tbl2")
                For i As Integer = 0 To DataTbl.Tables(0).Rows.Count - 1
                    Response.Write(DataTbl.Tables(0).Rows(i)("EffDte") & "<br/>")
                GridView1.DataSource = DataTbl.Tables(0)
                '----------- pretend clicked first row link
                Dim drwRow As DataRow = Nothing
                drwRow = DataTbl.Tables(0).Rows(0)
                '-- first row
                comComm = New OleDbCommand
                With comComm
                    .Connection = conConn
                    .CommandType = CommandType.Text
                    .CommandText = "SELECT * FROM AcessFileName WHERE (TblNbr = @TblNbr) ORDER BY LneNbr"
                    '.Parameters.AddWithValue("@TblNbr", drwRow("TaxDef"))
                    .Parameters.Add("@TblNbr", OleDbType.VarChar, 8)
                End With
                '-- loop throught the 8 fields
                For i As Integer = 0 To 7
                    If drwRow(17 + i) <> "00000000" Then
                        comComm.Parameters.Item("@TblNbr").Value = drwRow(17 + i)
                        adpAdap = New OleDbDataAdapter(comComm)
                        adpAdap.Fill(DataTbl, "tbl164")
                        For k As Integer = 0 To DataTbl.Tables("tbl164").Rows.Count - 1
                            'For i As Integer = 0 To DataTbl.Rows.Count - 1
                            Response.Write(DataTbl.Tables("tbl164").Rows(k)("TxtDat") & "<br/>")
                    End If
            Catch ex As Exception
                MsgBox("Error: Unable to read TTBS MS Access file into datatables. " & ex.Message & ex.StackTrace)
                If Not IsNothing(conConn) Then conConn.Close()
            End Try
        End Sub
    End Class

    • Moved by Alex-KSGZ Monday, April 8, 2019 9:20 AM
    Monday, April 8, 2019 8:37 AM

All replies

  • Hi,

    According to your description, your issue is more related about asp.net. And this forum is discussing and asking questions about the vb.net.
    Ask in the following forum.


    Thank you for your understanding.

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 8, 2019 8:43 AM
  • Thanks Alex
    Monday, April 8, 2019 8:51 AM