代码运行但不起作用? [英] code runs but don't work?
问题描述
为什么这段代码不起作用?我认为问题出在商务舱
code.when我从下拉列表中选择一个州,学校下拉列表
假设
来填写学校的名字,但不知何故,州的价值并没有回到商务舱的
。我认为这就是我使用财产获取和设置
访问者功能的方式。
****我的商务舱------- -----
''私有变量
'' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
私有共享myStateID字符串
公共共享函数GetSchoolByState (ByVal StateID As String)As DataSet
myStateID = StateID
Dim tool As New StuLotto.Accounts.Data.AccountsTool
返回工具.GetSchoolByStateList (myStateID)
结束功能
''属性
'' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
公共财产StateID()As String
获取
返回myStateID
结束获取
设置(ByVal值为字符串)
myStateID =值
结束集
结束财产
****我的CodeBehind类------------- ---
''通过选定状态下拉组合框绑定学校
Private Sub SStateDDL_SelectedIndexChanged(ByVal sender As
System.Object,ByVal e As System.EventArgs)Handles
SStateDDL.SelectedIndexChanged
将学校视为新数据集
Dim Value As String = SStateDDL.SelectedItem.Value
学校= Accounts.Business.AccountsTool.GetSchoolByState(Va lue)
SNameDDL.DataSource =学校
SNameDDL.DataTextField =" SchoolName"
SNameDDL .DataValueField =" SchoolID"
SNameDDL.DataBind()
End Sub
我没有看到你的小册子中任何地方都叫过StateID属性......
/ mortb
" Leon" < VN ***** @ msn.com>在消息中写道
news:ee ************** @ TK2MSFTNGP12.phx.gbl ...为什么这段代码没有工作?我认为问题出现在商务舱的代码中。当我从下拉列表中选择一个州时,学校下拉列表
想要填写学校名称,但不知何故,州的价值还没有得到回到商务舱。我认为这就是我使用财产获取和设置
访问者功能的方式。
****我的商务舱----------- - ''私人变量
'' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
私有共享myStateID为字符串
公共共享函数GetSchoolByState(ByVal StateID As String)As
DataSet
myStateID = StateID
Dim工具As New StuLotto.Accounts.Data.AccountsTool
返回工具.GetSchoolByStateList(myStateID)
结束功能
''属性
'' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
公共财产StateID( )作为字符串
获取
返回myStateID
结束获取
设置(ByVal值为字符串)
myStateID = value
结束集
结束正确ty
****我的CodeBehind类----------------
''通过选择状态下拉组合框绑定学校/> Private Sub SStateDDL_SelectedIndexChanged(ByVal sender As / / System.Object,ByVal e As System.EventArgs)句柄
SStateDDL.SelectedIndexChanged
Dim Schools As New DataSet
Dim Value As String = SStateDDL.SelectedItem.Value
Schools = Accounts.Business.AccountsTool.GetSchoolByState(Va lue)
SNameDDL.DataSource = Schools
SNameDDL.DataTextField =" SchoolName"
SNameDDL.DataValueField =" SchoolID"
SNameDDL.DataBind()
End Sub
如何解决这个问题?
" mortb" < mortb1< noospam< @ hotmail.com>在消息中写道
news:eD ************** @ TK2MSFTNGP15.phx.gbl ...我不是看到你的代码片段中任何地方调用的属性StateID ...
/ mortb
" Leon" < VN ***** @ msn.com>在消息中写道
新闻:ee ************** @ TK2MSFTNGP12.phx.gbl ...为什么这段代码不起作用?我认为问题出在业务上
类
代码。当我从下拉列表中选择一个州时,学校下拉列表
想要填写学校名称,但不知何故该州价值没有回到商务舱。我认为这就是我使用财产获取和设置
访问者功能的方式。
****我的商务舱------- -----
''私人变量
'' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
私有共享myStateID As String
公共共享函数GetSchoolByState(ByVal StateID As String)As
DataSet
myStateID = StateID
Dim工具As New StuLotto.Accounts.Data.AccountsTool
返回工具.GetSchoolByStateList(myStateID)
结束功能
''属性
'' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
公共属性StateID()As String
获取
返回myStateID
结束获取
设置(ByVal值为字符串)
myStateID = value
结束集
结束财产
****我的CodeBehind类----------------
''通过选择状态下拉组合框绑定学校<私有Sub SStateDDL_SelectedIndexChanged(ByVal发件人As / / System.Object,ByVal e As System.EventArgs)句柄
SStateDDL.SelectedIndexChanged
昏暗的学校作为新的数据集
昏暗的值作为字符串= SStateDDL.SelectedItem.Value
Schools = Accounts.Business.AccountsTool.GetSchoolByState(Va lue)
SNameDDL.DataSource = Schools
SNameDDL.DataTextField =" SchoolName"
SNameDDL。 DataValueField =" SchoolID"
SNameDDL.DataBind()
End Sub
< blockquote> Leon写道:
为什么这段代码不起作用?我认为问题出在业务类代码中。当我从下拉列表中选择一个状态时,学校
下拉列表假设要填写学校名称,但不知何故,状态值没有得到
回到商务舱。我认为这就是我使用财产的方式
获取和设置访问者功能。
****我的商务舱----------- - ''私人变量
'' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
私有共享myStateID作为字符串
公共共享函数GetSchoolByState(ByVal StateID As String)作为
DataSet myStateID = StateID
Dim工具As New StuLotto .Accounts.Data.AccountsTool
返回工具.GetSchoolByStateList(myStateID)
结束功能
''属性
'' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
公共属性StateID()As String
获取
返回myStateID
结束获取
设置(ByVal值为字符串)
myStateID = value
结束集
结束属性
*** *我的CodeBehind类----------------
''通过选定状态下拉组合框绑定学校
私有Sub SStateDDL_SelectedIndexChanged(ByVal发件人为
System.Object,ByVal e As System.EventArgs)句柄
SStateDDL.SelectedIndexChanged
昏暗的学校作为新数据集
Dim Value As String = SStateDDL.SelectedItem.Value
Schools = Accounts .Business.AccountsTool.GetSchoolByState(Va lue)
SNameDDL.DataSource =学校SNameDDL.DataTextField =" SchoolName" SNameDDL.DataValueField =" SchoolID"
SNameDDL.DataBind()
End Sub
调试此代码时,返回的内容是什么各种GetSchool
方法?你确定正确的状态吗?是否提供了价值?
您提到的财产从未使用过(在您公布的代码中)。
StateID第一种方法是局部变量。
Hans Kesting
Why this code is not working? I think the problem is in the business class
code.when I select a state from the dropdownlist, the school dropdownlist
suppose
to fill with school names, but somehow the state value is not getting back
to the business class. I think it''s the way I''m using property get and set
accessor function.
****My Business Class------------
'' Private variables
''- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
Private Shared myStateID As String
Public Shared Function GetSchoolByState(ByVal StateID As String) As DataSet
myStateID = StateID
Dim tool As New StuLotto.Accounts.Data.AccountsTool
Return tool.GetSchoolByStateList(myStateID)
End Function
'' Properties
''- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
Public Property StateID() As String
Get
Return myStateID
End Get
Set(ByVal value As String)
myStateID = value
End Set
End Property
****My CodeBehind Class----------------
'' Bind the school by selected state drop-down combobox
Private Sub SStateDDL_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
SStateDDL.SelectedIndexChanged
Dim Schools As New DataSet
Dim Value As String = SStateDDL.SelectedItem.Value
Schools = Accounts.Business.AccountsTool.GetSchoolByState(Va lue)
SNameDDL.DataSource = Schools
SNameDDL.DataTextField = "SchoolName"
SNameDDL.DataValueField = "SchoolID"
SNameDDL.DataBind()
End Sub
I don''t see the property StateID called anywhere in your sniplet...
/mortb
"Leon" <vn*****@msn.com> wrote in message
news:ee**************@TK2MSFTNGP12.phx.gbl...Why this code is not working? I think the problem is in the business class
code.when I select a state from the dropdownlist, the school dropdownlist
suppose
to fill with school names, but somehow the state value is not getting back
to the business class. I think it''s the way I''m using property get and set
accessor function.
****My Business Class------------
'' Private variables
''- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
Private Shared myStateID As String
Public Shared Function GetSchoolByState(ByVal StateID As String) As
DataSet
myStateID = StateID
Dim tool As New StuLotto.Accounts.Data.AccountsTool
Return tool.GetSchoolByStateList(myStateID)
End Function
'' Properties
''- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
Public Property StateID() As String
Get
Return myStateID
End Get
Set(ByVal value As String)
myStateID = value
End Set
End Property
****My CodeBehind Class----------------
'' Bind the school by selected state drop-down combobox
Private Sub SStateDDL_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
SStateDDL.SelectedIndexChanged
Dim Schools As New DataSet
Dim Value As String = SStateDDL.SelectedItem.Value
Schools = Accounts.Business.AccountsTool.GetSchoolByState(Va lue)
SNameDDL.DataSource = Schools
SNameDDL.DataTextField = "SchoolName"
SNameDDL.DataValueField = "SchoolID"
SNameDDL.DataBind()
End Sub
How do I fix that problem?
"mortb" <mortb1<noospam<@hotmail.com> wrote in message
news:eD**************@TK2MSFTNGP15.phx.gbl...I don''t see the property StateID called anywhere in your sniplet...
/mortb
"Leon" <vn*****@msn.com> wrote in message
news:ee**************@TK2MSFTNGP12.phx.gbl...Why this code is not working? I think the problem is in the business
class
code.when I select a state from the dropdownlist, the school dropdownlist
suppose
to fill with school names, but somehow the state value is not getting
back
to the business class. I think it''s the way I''m using property get and
set
accessor function.
****My Business Class------------
'' Private variables
''- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
Private Shared myStateID As String
Public Shared Function GetSchoolByState(ByVal StateID As String) As
DataSet
myStateID = StateID
Dim tool As New StuLotto.Accounts.Data.AccountsTool
Return tool.GetSchoolByStateList(myStateID)
End Function
'' Properties
''- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
Public Property StateID() As String
Get
Return myStateID
End Get
Set(ByVal value As String)
myStateID = value
End Set
End Property
****My CodeBehind Class----------------
'' Bind the school by selected state drop-down combobox
Private Sub SStateDDL_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
SStateDDL.SelectedIndexChanged
Dim Schools As New DataSet
Dim Value As String = SStateDDL.SelectedItem.Value
Schools = Accounts.Business.AccountsTool.GetSchoolByState(Va lue)
SNameDDL.DataSource = Schools
SNameDDL.DataTextField = "SchoolName"
SNameDDL.DataValueField = "SchoolID"
SNameDDL.DataBind()
End Sub
Leon wrote:Why this code is not working? I think the problem is in the business
class code.when I select a state from the dropdownlist, the school
dropdownlist suppose
to fill with school names, but somehow the state value is not getting
back to the business class. I think it''s the way I''m using property
get and set accessor function.
****My Business Class------------
'' Private variables
''- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
Private Shared myStateID As String
Public Shared Function GetSchoolByState(ByVal StateID As String) As
DataSet myStateID = StateID
Dim tool As New StuLotto.Accounts.Data.AccountsTool
Return tool.GetSchoolByStateList(myStateID)
End Function
'' Properties
''- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
Public Property StateID() As String
Get
Return myStateID
End Get
Set(ByVal value As String)
myStateID = value
End Set
End Property
****My CodeBehind Class----------------
'' Bind the school by selected state drop-down combobox
Private Sub SStateDDL_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
SStateDDL.SelectedIndexChanged
Dim Schools As New DataSet
Dim Value As String = SStateDDL.SelectedItem.Value
Schools = Accounts.Business.AccountsTool.GetSchoolByState(Va lue)
SNameDDL.DataSource = Schools SNameDDL.DataTextField = "SchoolName" SNameDDL.DataValueField = "SchoolID"
SNameDDL.DataBind()
End Sub
When you debug this code, what is returned by the various "GetSchool"
methods? Are you sure the correct "state" value is supplied?
The property you mention is never used (in your published code).
The "StateID" in the first method is a local variable.
Hans Kesting
这篇关于代码运行但不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!