Actualy i still have a problem
on this page
http://worldgolfdata.com/Enter/Default.aspx
i have a list of countries when you click on them you get a list of states,
click on a state youi get a list of golf courses from that state.
I have a little bit of test data in it, if you go to Australia, then select
either Victoria or Western Australia you will get a list of 1 or 2 courses
repectivly.
I also have a lale that shows what event handler has fired.
if you have a play you will se that when you change state from victoria to
western australia then click on a course the lable shows that the event
handler does not fire till you click the second time.
Can you tell me why and suggets a fix or a workaround?
here is the code
Partial Class Enter_Default
Inherits System.Web.UI.Page
Protected Sub Page_PreLoad(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
buildCountrys()
If ViewState("buildStates") <> "" Then
buildStates()
End If
If ViewState("buildCourses") <> "" Then
buildCourses()
End If
End Sub
Sub buildCountrys()
Dim oCountries As Countries
oCountries = New Countries
Dim i As Integer
For i = 0 To UBound(oCountries.getCountries)
Dim tr As TableRow = New TableRow
Dim td As TableCell = New TableCell
Dim linkCountry As LinkButton = New LinkButton
AddHandler linkCountry.Click, AddressOf CountryButtClick
linkCountry.OnClientClick = "waitForIt()"
linkCountry.Attributes.Add("class", "dButtons")
linkCountry.CommandArgument = oCountries.getCountries(i).id
linkCountry.Text = oCountries.getCountries(i).Name
td.Controls.Add(linkCountry)
tr.Cells.Add(td)
countryTable.Rows.Add(tr)
Next
End Sub
Sub buildStates()
stateTable.Rows.Clear()
courseTable.Rows.Clear()
Dim oCountry As Country
oCountry = New Country(ViewState("buildStates"))
Dim i As Integer
For i = 0 To UBound(oCountry.getStates)
'On Error Resume Next
Dim tr As TableRow = New TableRow
Dim td As TableCell = New TableCell
Dim linkState As LinkButton = New LinkButton
AddHandler linkState.Click, AddressOf StateButtClick
linkState.OnClientClick = "waitForIt()"
linkState.Attributes.Add("class", "dButtons")
linkState.CommandArgument = oCountry.getStates(i).id
linkState.Text = oCountry.getStates(i).Name
td.Controls.Add(linkState)
tr.Cells.Add(td)
stateTable.Rows.Add(tr)
Next
End Sub
Sub buildCourses()
courseTable.Rows.Clear()
Dim oState As State
oState = New State(ViewState("buildCourses"))
Dim i As Integer
For i = 0 To UBound(oState.getCourses)
If oState.countCourses > 0 Then
Dim tr As TableRow = New TableRow
Dim td As TableCell = New TableCell
Dim linkCourse As LinkButton = New LinkButton
AddHandler linkCourse.Click, AddressOf CourseButtClick
linkCourse.OnClientClick = "waitForIt()"
linkCourse.Attributes.Add("class", "dButtons")
linkCourse.CommandArgument = oState.getCourses(i).id
linkCourse.Text = oState.getCourses(i).Name
td.Controls.Add(linkCourse)
courseTable.Rows.Add(tr)
tr.Cells.Add(td)
Else
End If
Next
End Sub
Sub CountryButtClick(ByVal sender As Object, ByVal e As EventArgs)
ViewState.Add("buildStates", sender.CommandArgument)
Label1.Text = "country clicked"
buildStates()
End Sub
Sub StateButtClick(ByVal sender As Object, ByVal e As EventArgs)
ViewState.Add("buildCourses", sender.CommandArgument)
Label1.Text = "state clicked"
buildCourses()
End Sub
Sub CourseButtClick(ByVal sender As Object, ByVal e As EventArgs)
Label1.Text = "course clicked"
End Sub
End Class