System.NullReferenceException: Object variable or With block variable not set
on this line.
TextBox1.Text = Trim(Row.Item("eng_lbl"))
I am trying to display the values of a record from the table in 4 text box fields.
I am new to asp.net. Please kindly help.
You're not assign row to anything..
Dim mydataset As New DataSet
Dim myadapter As New SqlDataAdapter
Dim strId As String = Request.QueryString("lbl_Id")
Dim RowDim myCommand As New SqlClient.SqlCommand
Dim sql As String = "select * from tbl_labels where id =" & CInt(strId)
If Not Page.IsPostBack Then
MyCommand = New SqlCommand(sql, MyConnection)myadapter = New SqlDataAdapter(myCommand)
mydataset.Clear()
myadapter.Fill(mydataset)If mydataset.Tables(0).Rows.Count > 0 Then
TextBox1.Text = Trim(Row.Item("eng_lbl"))
TextBox2.Text = Trim(Row.Item("esp_lbl"))
TextBox3.Text = Trim(Row.Item("fr_lbl"))
TextBox4.Text = Trim(Row.Item("ger_lbl"))
End If
End If
I.E.
Dim Row As DataRowIf mydataset.Tables(0).Rows.Count > 0 Then
Row = mydataset.Tables(0).Rows(0)
TextBox1.Text = Trim(Row.Item("eng_lbl"))
TextBox2.Text = Trim(Row.Item("esp_lbl"))
TextBox3.Text = Trim(Row.Item("fr_lbl"))
TextBox4.Text = Trim(Row.Item("ger_lbl"))
End If
0 comments:
Post a Comment