Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

bind datatable columns data to a specific 1 datagridviewer column

$
0
0

Hi, I have extracted one row of data with multiple columns from an excel file to a Datatable, and I tried to bind all this data to one specific column on a datagridviewer called "index". with the code below, if I use 

DataGridView3.Rows.Add(row.ItemArray), it only gives me the first cell of the datatable. If I use DataGridView3.DataSource=dt5, it puts all data horizontaly instead of what I want vertically. any idea ? thanks

 Using cn As New OleDbConnection With {.ConnectionString = String.Format(ConnectionNoHeader3, FileName3)}
            cn.Open()
            Dim cmd As OleDbCommand = New OleDbCommand(<Text>
                    SELECT 
                        *
                    FROM [<%= SheetName3 %>$]
where date=<%= CStr(CurrentWeek) %></Text>.Value,
                    cn
            )
            Dim dt5 As New DataTable
            dt5.Load(cmd.ExecuteReader)
            For Each row As DataRow In dt5.Rows
                DataGridView3.Rows.Add(row.ItemArray)
            Next
DataGridView.DataSource=dt5
        End Using


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>