how to display data in textboxes ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i'm trying to display the data into the textboxes when the user enters the appropriate id in the search textfield, however, it keeps on displaying an error message such as the following on my pocket pc

An unhandled exception of type 'System.ArgumentNullException' occurred in System.Windows.Forms.dll

Additional information: ArgumentNullException...

My codes are such as below.My web services was ok..when i enter the number, it works fine..
Private Sub Search2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Search2.Click
Dim sID As Integer
sID = Convert.ToInt32(TextBox1.Text)
Dim ws As New servername.Service1
Dim ds As DataSet = ws.GetJobID(sID)
Dim dt As DataTable = ds.Tables("Jobs")
TextBox2.DataBindings.Add("Text", dt, "JobID")
TextBox3.DataBindings.Add("Text", dt, "JobNumber")
TextBox4.DataBindings.Add("Text", dt, "JobName")
End Sub
 
I think you can try:

TextBox2.text = dt.rows.Item(0).Item("JobID")
and so on.

I assume that there is only one record that matches.

Kempton
 
It is because there is no ToString method from Item class. Simply delete the .ToString should work. Moreover, since you can't change the record to string, I think it is better to catch error. Besides, dt.Rows.Item(0) meets the first row, so if you want all data from the save row, you should do:

try
TextBox2.Text = dt.Rows.Item(0).Item("JobID")
TextBox3.Text = dt.Rows.Item(0).Item("JobNumber")
TextBox4.Text = dt.Rows.Item(0).Item("JobName")
catch ex as exception
MsgBox(ex.message, MsgBoxStyle.Critical)
end try

I hope it could help you.
 
hi...thanks alot..able to retrive the data already..made some mistake earlier because i tought the item(0) stands for the column number.
 
Back
Top