vb.netoption-strict

Late Binding Vb .Net


Trying to set my labels text to = the value of a specific row & columns value. I prefer to use Option Strict On but its disallowing the late binding. Ideas?

Private Sub BuildText(ByVal dtData As DataTable)
    Try
        lblVendor.Text = CType(CStr(dtData.Rows(0)("Vendor").value), String)
    Catch ex As Exception

    End Try
End Sub

Solution

  • To get the value you can use Field(Of T)

    lblVendor.Text = dtData.Rows(0).Field(Of String)("Vendor")
    

    DataRowExtensions.Field(Of T) Method (DataRow, String)

    To use this you'll need to add a reference to System.Data.DataSetExtensions