为文本框指定值 [英] assign value to a text box

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

问题描述

我有以下代码:


为初学者提供txtempid的值= 1

我完成这个程序后(我给了一个断点) txtname.value

行),txtEmpID的值是2(就像它假设的那样)

然而,当我再次进入这个函数时,txtEmpID = 1再次

由于某种原因,txtEmpID.value没有保留其实际值2


任何想法?

尝试


Dim row As DataRow = ds.Tables(" TestTable")。选择(" emp_id>"&

txtEmpID.Value )(0)


带行


txtEmpID.Value = .Item(" emp_id")。ToString


txtFName.Value = .Item(" Fname")。ToString


txtLName.Value = .Item(" LName")。ToString


结束


Catch err As Exception


lblError.Text =" No Previous records" &安培; err.ToString()


结束尝试

i have the code below:

for starters the value of txtempid = 1
after i go through this routine (i put a break point on the txtname.value
line), the value of txtEmpID is 2 (Just like it is suppose to be)
However, when i come into this function again, txtEmpID = 1 again
For some reason the txtEmpID.value isn''t retaining its actual value of 2

any ideas?
Try

Dim row As DataRow = ds.Tables("TestTable").Select("emp_id > " &
txtEmpID.Value)(0)

With row

txtEmpID.Value = .Item("emp_id").ToString

txtFName.Value = .Item("Fname").ToString

txtLName.Value = .Item("LName").ToString

End With

Catch err As Exception

lblError.Text = "No Previous records " & err.ToString()

End Try

推荐答案

你没有发布功能;你发布了一段代码。如果您发布该功能,它会帮助

,因为问题在于你如何初始化
< txtEmpID"我强烈怀疑你是在

函数定义中初始化它。这将导致每次初始化

函数被调用。


-

HTH,

Kevin Spencer

..Net开发商

微软MVP

大件东西组成

of很多小事。


" Mark Kurten" <毫安********* @ acordia.com>在消息中写道

新闻:#D ************* @ TK2MSFTNGP10.phx.gbl ...
You didn''t post a function; you posted a block of code. It would have helped
if you DID post the function, because the problem lies in how you
initialized "txtEmpID" and I strongly suspect that you initialized it in the
function definition. This would result in its being initialized every time
the function is called.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Mark Kurten" <ma*********@acordia.com> wrote in message
news:#D*************@TK2MSFTNGP10.phx.gbl...
我的代码如下:

对于初学者来说txtempid的值= 1
在我完成这个例程之后(我在txtname.value上放了一个断点),txtEmpID的值是2(就像它假设的那样)
然而,当我再次进入这个函数时,txtEmpID = 1再次
由于某种原因,txtEmpID.value不保留其实际值2

任何想法?
尝试

Dim row As DataRow = ds.Tables(" TestTable")。选择(" emp_id>"&
txtEmpID.Value)(0)


txtEmpID.Value = .Item(" emp_id")。ToString

txtFName.Value = .Item(" Fname")。ToString

txtLName.Value = .Item(" LName")。ToString

结束

将错误视为例外

lblError.Text =" No Previous records" &安培; err.ToString()

结束尝试
i have the code below:

for starters the value of txtempid = 1
after i go through this routine (i put a break point on the txtname.value
line), the value of txtEmpID is 2 (Just like it is suppose to be)
However, when i come into this function again, txtEmpID = 1 again
For some reason the txtEmpID.value isn''t retaining its actual value of 2

any ideas?
Try

Dim row As DataRow = ds.Tables("TestTable").Select("emp_id > " &
txtEmpID.Value)(0)

With row

txtEmpID.Value = .Item("emp_id").ToString

txtFName.Value = .Item("Fname").ToString

txtLName.Value = .Item("LName").ToString

End With

Catch err As Exception

lblError.Text = "No Previous records " & err.ToString()

End Try



这是函数..


Private Sub btnNext_ServerClick(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理btnPrev.ServerClick

尝试


Dim row As DataRow = ds.Tables(" TestTable")。选择(" emp_id>"&

txtEmpID.Value)(0)


带行


txtEmpID.Value = .Item(" emp_id")。ToString


txtFName.Value = .Item(" Fname")。ToString


txtLName.Value = .Item(" LName")。ToString


结束


Catch err As Exception


lblError.Text =" No Nextrecords" &安培; err.ToString()


结束尝试


End Sub


" Kevin Spencer" <柯*** @ takempis.com>在消息中写道

新闻:OC ************* @ TK2MSFTNGP12.phx.gbl ...
Here is the function..

Private Sub btnNext_ServerClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPrev.ServerClick
Try

Dim row As DataRow = ds.Tables("TestTable").Select("emp_id > " &
txtEmpID.Value)(0)

With row

txtEmpID.Value = .Item("emp_id").ToString

txtFName.Value = .Item("Fname").ToString

txtLName.Value = .Item("LName").ToString

End With

Catch err As Exception

lblError.Text = "No Nextrecords " & err.ToString()

End Try

End Sub

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:OC*************@TK2MSFTNGP12.phx.gbl...
你没有发帖功能;你发布了一段代码。如果您发布该功能,它将有
帮助,因为问题在于您如何初始化txtEmpID。我强烈怀疑你在
函数定义中初始化它。这将导致每次调用函数时对其进行初始化。

-
HTH,
Kevin Spencer
.Net Developer 微软MVP
很多小东西组成了很多东西。

Mark Kurten <毫安********* @ acordia.com>在消息中写道
新闻:#D ************* @ TK2MSFTNGP10.phx.gbl ...
You didn''t post a function; you posted a block of code. It would have helped if you DID post the function, because the problem lies in how you
initialized "txtEmpID" and I strongly suspect that you initialized it in the function definition. This would result in its being initialized every time
the function is called.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Mark Kurten" <ma*********@acordia.com> wrote in message
news:#D*************@TK2MSFTNGP10.phx.gbl...
我的代码如下:

对于初学者来说txtempid的值= 1
在我完成这个例程之后(我在
txtname.value行上放了一个断点),txtEmpID的值是2(就像它是假设是)
然而,当我再次进入这个函数时,txtEmpID = 1再次
由于某种原因,txtEmpID.value不保留其实际值2

任何想法?
尝试

Dim row As DataRow = ds.Tables(" TestTable")。选择(" emp_id>"&
txtEmpID .Value)(0)


txtEmpID.Value = .Item(" emp_id")。ToString

txtFName.Value = .Item(" Fname")。ToString

txtLName.Value = .Item(" LName")。ToString

结束

Catch err As Exception

lblError.Text =" No Previous records" &安培; err.ToString()

结束尝试
i have the code below:

for starters the value of txtempid = 1
after i go through this routine (i put a break point on the txtname.value line), the value of txtEmpID is 2 (Just like it is suppose to be)
However, when i come into this function again, txtEmpID = 1 again
For some reason the txtEmpID.value isn''t retaining its actual value of 2

any ideas?
Try

Dim row As DataRow = ds.Tables("TestTable").Select("emp_id > " &
txtEmpID.Value)(0)

With row

txtEmpID.Value = .Item("emp_id").ToString

txtFName.Value = .Item("Fname").ToString

txtLName.Value = .Item("LName").ToString

End With

Catch err As Exception

lblError.Text = "No Previous records " & err.ToString()

End Try




好的,它看起来就像当你说当我再次进入这个功能时时那么... b / b
你在谈论一个PostBack?如果是这样,你的TextBox控件'

EnableViewState属性是否设置为True?


-

HTH,

Kevin Spencer

..Net开发人员

微软MVP

大项目组成

很多小东西。


" Mark Kurten" <毫安********* @ acordia.com>在消息中写道

新闻:OX ************** @ TK2MSFTNGP11.phx.gbl ...
Okay, it looks like when you say "when I come into this function again"
you''re talking about a PostBack? If so, is your TextBox control''s
EnableViewState property set to True?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Mark Kurten" <ma*********@acordia.com> wrote in message
news:OX**************@TK2MSFTNGP11.phx.gbl...
这是函数。 。

Private Sub btnNext_ServerClick(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理btnPrev.ServerClick

尝试

Dim row As DataRow = ds.Tables(" TestTable")。选择(" emp_id>"&
txtEmpID.Value)(0)

带行

txtEmpID.Value = .Item(" emp_id")。ToString

txtFName.Value = .Item(" Fname")。ToString
txtLName.Value = .Item(" LName")。ToString

结束

将错误视为例外

lblError.Text =" ;没有Nextrecords &安培; err.ToString()

结束尝试

End Sub

Kevin Spencer <柯*** @ takempis.com>在消息中写道
新闻:OC ************* @ TK2MSFTNGP12.phx.gbl ...
Here is the function..

Private Sub btnNext_ServerClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPrev.ServerClick
Try

Dim row As DataRow = ds.Tables("TestTable").Select("emp_id > " &
txtEmpID.Value)(0)

With row

txtEmpID.Value = .Item("emp_id").ToString

txtFName.Value = .Item("Fname").ToString

txtLName.Value = .Item("LName").ToString

End With

Catch err As Exception

lblError.Text = "No Nextrecords " & err.ToString()

End Try

End Sub

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:OC*************@TK2MSFTNGP12.phx.gbl...
你没有发布功能;你发布了一段代码。它会
You didn''t post a function; you posted a block of code. It would have


帮助

如果您发布该功能,因为问题在于您如何初始化txtEmpID。我强烈怀疑你是在
if you DID post the function, because the problem lies in how you
initialized "txtEmpID" and I strongly suspect that you initialized it in

函数定义中初始化它。这将导致每个
时间初始化
function definition. This would result in its being initialized every time
该函数被调用。

-
HTH,
Kevin Spencer
.Net开发人员
Microsoft MVP
很多小东西都是由大事组成的。

Mark Kurten ; <毫安********* @ acordia.com>在消息中写道
新闻:#D ************* @ TK2MSFTNGP10.phx.gbl ...
the function is called.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Mark Kurten" <ma*********@acordia.com> wrote in message
news:#D*************@TK2MSFTNGP10.phx.gbl...
我的代码如下:
对于初学者来说,txtempid的值= 1
在我完成这个例程后(我在
i have the code below:

for starters the value of txtempid = 1
after i go through this routine (i put a break point on the


txtname.value行上设置了一个断点), txtEmpID的值是2(就像它假设的那样)
然而,当我再次进入这个函数时,txtEmpID = 1再次
由于某种原因,txtEmpID.value并没有保留它的实际值价值
2
任何想法?
尝试

Dim row As DataRow = ds.Tables(" TestTable")。选择(" emp_id>" ;&
txtEmpID.Value)(0)



txtEmpID.Value = .Item(" emp_id")。ToString

txtFName.Value = .Item(" Fname")。ToString

txtLName.Value = .Item(" LName")。ToString

结束

将错误视为例外

lblError.Text =" No Previous records" &安培; err.ToString()

结束尝试


txtname.value line), the value of txtEmpID is 2 (Just like it is suppose to be)
However, when i come into this function again, txtEmpID = 1 again
For some reason the txtEmpID.value isn''t retaining its actual value of 2
any ideas?
Try

Dim row As DataRow = ds.Tables("TestTable").Select("emp_id > " &
txtEmpID.Value)(0)

With row

txtEmpID.Value = .Item("emp_id").ToString

txtFName.Value = .Item("Fname").ToString

txtLName.Value = .Item("LName").ToString

End With

Catch err As Exception

lblError.Text = "No Previous records " & err.ToString()

End Try




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

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