ahmed fahd

ahmed fahd

  • NA
  • 58
  • 46.1k

how to allocate datatable rows to datagridview rows

Jan 9 2013 1:32 PM
i want to give the rows using their index in the both (datatable , datagrid)
to datagrid
i tried this but wasn't suitable or has problem

    Dim i As Integer = 1

        For Each r As DataRow In dt.Rows
       
            DataGridView1.SelectedRows(i).Cells("emp_name") = dt.Rows(i)("Emp_Name")
            DataGridView1.SelectedRows(i).Cells("emp_id") = dt.Rows(i)("Emp_ID")

            DataGridView1.SelectedRows(i).Cells("date_") = dt.Rows(i)("Day_Dat")

            i = i + 1
        Next
is there another solution?