code runs but don't work?

L

Leon

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(Value)
SNameDDL.DataSource = Schools
SNameDDL.DataTextField = "SchoolName"
SNameDDL.DataValueField = "SchoolID"
SNameDDL.DataBind()
End Sub
 
H

Hans Kesting

Leon said:
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(Value)
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
 
L

Leon

nothing is returned. I also change my code to the following and it does not
work, but compile errors.

' 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 = Accounts.Business.AccountsTool.StateID =
SStateDDL.SelectedItem.Value.ToString

Schools = Accounts.Business.AccountsTool.GetSchoolByState(Value)

SNameDDL.DataSource = Schools

SNameDDL.DataTextField = "SchoolName"

SNameDDL.DataValueField = "SchoolID"

SNameDDL.DataBind()

End Sub
 
M

mortb

Problem? It may not be a problem. It depends on what you want to do.
The funciton GetSchoolByState(ByVal StateID As String)
takes a StateID and sets the private variable myStateID. The get/set
accessor is never called in your example but may be somewhere else in your
program.
You should debug and see what is passed into GetSchoolByState.
If the right value is passed the problem lies in the function
GetSchoolByState calls.

cheers,
mortb
 
M

mortb

then we would see
string X = Accounts.Business.AccountsTool.StateID
or
Accounts.Business.AccountsTool.StateID = "foo"
in your codebehind code
 
L

Leon

it's still not working even when I try..What should I do? Thanks!
then we would see
string X = Accounts.Business.AccountsTool.StateID
or
Accounts.Business.AccountsTool.StateID = "foo"
in your codebehind code
 
J

Jeff Dillon

In the debugger!!

Leon said:
nothing is returned. I also change my code to the following and it does not
work, but compile errors.

' 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 = Accounts.Business.AccountsTool.StateID =
SStateDDL.SelectedItem.Value.ToString

Schools = Accounts.Business.AccountsTool.GetSchoolByState(Value)

SNameDDL.DataSource = Schools

SNameDDL.DataTextField = "SchoolName"

SNameDDL.DataValueField = "SchoolID"

SNameDDL.DataBind()

End Sub
 
L

Leon

I got it! Thanks for all the help!!!!
Leon said:
it's still not working even when I try..What should I do? Thanks!
then we would see
string X = Accounts.Business.AccountsTool.StateID
or
Accounts.Business.AccountsTool.StateID = "foo"
in your codebehind code
 
J

Jeff Dillon

You still haven't used the debugger, have you. trust me, it's a good thing
to learn

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top