将数据绑定到文本框 [英] bind data to textboxes

查看:97
本文介绍了将数据绑定到文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调用一个组件来获取我的数据。该组件返回了一个

数据集。我需要在我的aspx页面上填充文本框,其中的数据是

datalist。

我在哪里可以找到这样做的例子?


这是我正在使用的代码,我得到了一个错误:

代码:


尝试

dbConn.GetCarInformation(CarID)

Dim cmd As Oracle.DataAccess.Client.OracleCommand

Dim da As Oracle.DataAccess.Client.OracleDataReader

da = cmd.ExecuteReader(CommandBehavior.SingleRow)

如果da.Read那么

txtCarName.Text = da(" Model")。ToString

结束如果

Catch ex As Exception

lblError.Text ="错误:" &安培; ex.Message

结束尝试


错误:


对象引用未设置为对象的实例。

我做错了什么?我不想使用datalist我只是想

填充文本框

解决方案

"麦克" <弥** @ discussions.microsoft.com>在留言中写道

news:7B ********************************** @ microsof t.com ...

我正在调用一个组件来获取我的数据。该组件正在返回一个
数据集。我需要在我的aspx页面上填充文本框中的数据
在datalist中。
我在哪里可以找到一个这样做的例子?

这是代码我正在使用并且我得到了一个错误:
代码:

尝试使用dbConn.GetCarInformation(CarID)
Dim cmd作为Oracle.DataAccess .Client.OracleCommand




您从未创建过实例。尝试:


Dim cmd As New Oracle.DataAccess.Client.OracleCommand


John Saunders

我现在有这个:

尝试

dbConn.GetCarInformation(CarID)

Dim cmd作为Oracle.DataAccess.Client.OracleCommand

Dim da As Oracle.DataAccess.Client.OracleDataReader

cmd = new Oracle.DataAccess.Client.OracleCommand

da = cmd.ExecuteReader( CommandBehavior.SingleRow)

如果是da.Read那么

txtCarName.Text = da(" Model")。ToString

结束如果

Catch ex As Exception

lblError.Text ="错误:" &安培; ex.Message

结束尝试


现在我收到此错误:

错误:操作无效到期目标状态。


" John Saunders"写道:

" Mike" <弥** @ discussions.microsoft.com>在消息中写道
新闻:7B ********************************** @ microsof t.com。 ..

我正在调用一个组件来获取我的数据。该组件正在返回一个
数据集。我需要在我的aspx页面上填充文本框中的数据
在datalist中。
我在哪里可以找到一个这样做的例子?

这是代码我正在使用并且我得到了一个错误:
代码:

尝试使用dbConn.GetCarInformation(CarID)
Dim cmd作为Oracle.DataAccess .Client.OracleCommand



您从未创建过实例。尝试:

Dim cmd As New Oracle.DataAccess.Client.OracleCommand

John Saunders


"麦克" <弥** @ discussions.microsoft.com>在消息中写道

news:7E ********************************** @ microsof t.com ...

我现在有这个:
尝试dbConn.GetCarInformation(CarID)
Dim cmd As Oracle.DataAccess.Client.OracleCommand
Dim da As Oracle.DataAccess.Client.OracleDataReader
cmd = new Oracle.DataAccess.Client.OracleCommand
da = cmd.ExecuteReader(CommandBehavior.SingleRow)
如果da.Read那么
txtCarName.Text = da(" Model")。ToString
结束如果
Catch ex Exception
lblError.Text ="错误:" &安培; ex.Message
结束尝试

现在我收到此错误:
错误:由于对象的当前状态,操作无效。




你不需要在cmd.Connection中打开一个OracleConnection吗?


John Saunders


I''m calling a component to get my data. The component is returning a
dataset. I need to populate text boxes on my aspx page with the data within
the datalist.
Where can I find an example that does this?

Here is the code i''m using and i''m gettting an error:
code:

Try
dbConn.GetCarInformation(CarID)
Dim cmd As Oracle.DataAccess.Client.OracleCommand
Dim da As Oracle.DataAccess.Client.OracleDataReader
da = cmd.ExecuteReader(CommandBehavior.SingleRow)
If da.Read Then
txtCarName.Text = da("Model").ToString
End If
Catch ex As Exception
lblError.Text = "Error: " & ex.Message
End Try

error:

Object reference not set to an instance of an object.
what am i doing wrong? I don''t want to use a datalist i just want to
populate the textboxes

解决方案

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...

I''m calling a component to get my data. The component is returning a
dataset. I need to populate text boxes on my aspx page with the data
within
the datalist.
Where can I find an example that does this?

Here is the code i''m using and i''m gettting an error:
code:

Try
dbConn.GetCarInformation(CarID)
Dim cmd As Oracle.DataAccess.Client.OracleCommand



You never created an instance. Try:

Dim cmd As New Oracle.DataAccess.Client.OracleCommand

John Saunders


I have this now:
Try
dbConn.GetCarInformation(CarID)
Dim cmd As Oracle.DataAccess.Client.OracleCommand
Dim da As Oracle.DataAccess.Client.OracleDataReader
cmd = new Oracle.DataAccess.Client.OracleCommand
da = cmd.ExecuteReader(CommandBehavior.SingleRow)
If da.Read Then
txtCarName.Text = da("Model").ToString
End If
Catch ex As Exception
lblError.Text = "Error: " & ex.Message
End Try

and now i''m getting this error:
Error: Operation is not valid due to the current state of the object.

"John Saunders" wrote:

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...

I''m calling a component to get my data. The component is returning a
dataset. I need to populate text boxes on my aspx page with the data
within
the datalist.
Where can I find an example that does this?

Here is the code i''m using and i''m gettting an error:
code:

Try
dbConn.GetCarInformation(CarID)
Dim cmd As Oracle.DataAccess.Client.OracleCommand



You never created an instance. Try:

Dim cmd As New Oracle.DataAccess.Client.OracleCommand

John Saunders



"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:7E**********************************@microsof t.com...

I have this now:
Try
dbConn.GetCarInformation(CarID)
Dim cmd As Oracle.DataAccess.Client.OracleCommand
Dim da As Oracle.DataAccess.Client.OracleDataReader
cmd = new Oracle.DataAccess.Client.OracleCommand
da = cmd.ExecuteReader(CommandBehavior.SingleRow)
If da.Read Then
txtCarName.Text = da("Model").ToString
End If
Catch ex As Exception
lblError.Text = "Error: " & ex.Message
End Try

and now i''m getting this error:
Error: Operation is not valid due to the current state of the object.



Don''t you need an open OracleConnection in cmd.Connection?

John Saunders


这篇关于将数据绑定到文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆