KentDBerry
asked on
How to set an unbound textbox to value of a datatable
In the below code the IsLoggedOn() function sets the two global variables gbAdmin and gbDeveloper to True/False. I have two unbound textboxes that I want to set to the values based on who is logged in.
The below code generates the following error: NullReferenceException Occurred on the me.txtUsername.Text line of code
What do I need to do to resolve?
The below code generates the following error: NullReferenceException Occurred on the me.txtUsername.Text line of code
What do I need to do to resolve?
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
IsLoggedOn()
Me.TblApplicationParametersTableAdapter.Fill(Me.BRDWorkslatesDataSet.tblApplicationParameters)
Me.TblReportOptionsTableAdapter.Fill(Me.ReportOptions.tblReportOptions)
If gbAdmin = True Then
Me.txtUserName.Text = Me.BRDWorkslatesDataSet.tblApplicationParameters.Columns("AdminUserNameColumn").ToString
Me.txtPassword.Text = Me.BRDWorkslatesDataSet.tblApplicationParameters.Columns("AdminPasswordColumn").ToString
ElseIf gbDeveloper = True Then
Me.txtUserName.Text = Me.BRDWorkslatesDataSet.tblApplicationParameters.Columns("DeveloperUserNameColumn").ToString
Me.txtPassword.Text = Me.BRDWorkslatesDataSet.tblApplicationParameters.Columns("DeveloperPasswordColumn").ToString
End If
End Sub
ASKER
Bob,
thx. You are correct, so I changed the line to the following, and I now get "AdminUserName" returned as the value. If I want to return the value of the data what would I have to do.
thx. You are correct, so I changed the line to the following, and I now get "AdminUserName" returned as the value. If I want to return the value of the data what would I have to do.
Me.txtUserName.Text = Me.BRDWorkslatesDataSet.tblApplicationParameters.Columns("AdminUserName").ToString
Me.txtPassword.Text = Me.BRDWorkslatesDataSet.tblApplicationParameters.Columns("AdminPassword").ToString
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Bob