Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdown selection not working

Status
Not open for further replies.

arada1

MIS
Dec 3, 2006
47
US
hi folks,
I have a asp.net page where a user can select from the dropdown menu.if the user select "--year--" from the dropdown menu I would like to show a message Please select a year.If I select "--Year--" first time I am able to see the message but if I select 1999 and try to select "--Year--" this time I am not able to see the message. can someone point me why this is happening


Sub LetYear()
LettingYear.Items.Insert(0, New ListItem("--Year--", 0))
LettingYear.Items.Insert(1, New ListItem("1999", 1))
LettingYear.Items.Insert(2, New ListItem("2000", 2))
LettingYear.Items.Insert(3, New ListItem("2001", 3))
LettingYear.Items.Insert(4, New ListItem("2002", 4))
LettingYear.Items.Insert(5, New ListItem("2003", 5))
LettingYear.Items.Insert(6, New ListItem("2004", 6))
LettingYear.Items.Insert(7, New ListItem("2005", 7))
LettingYear.Items.Insert(8, New ListItem("2006", 8))
LettingYear.Items.Insert(9, New ListItem("2007", 9))
End Sub

Function GetConnectionString() As String
Return ConfigurationManager.ConnectionStrings("costEstimating").ConnectionString
End Function

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

If LettingYear.SelectedValue.ToString = "0" Then
lblMessage.Text = "Please select year...."
Else
lblMessage.Text = "Your query results...."
Dim LetYr As String = LettingYear.SelectedItem.ToString


'Dim oOracleConn As OracleConnection
Dim connectionString As String = ConnectionStrings("costEstimating").ConnectionString
Dim oOracleConn As OracleConnection = New OracleConnection(connectionString)

Dim strSQLforLetting As String = "SELECT DISTINCT to_char(datelet,'MM/DD/YYYY') ""Letting Date"", letting ""Letting Id"" "
strSQLforLetting = strSQLforLetting & " FROM bidlet WHERE SUBSTR (letting, 7, 2) = '01' and timelet='9:30 A.M.' "
strSQLforLetting = strSQLforLetting & " AND TO_CHAR (datelet, 'YYYY') =" & LetYr

Dim cmdLetyear As OracleCommand = New OracleCommand(strSQLforLetting, New OracleConnection(GetConnectionString()))
Dim adpLetyear As New OracleDataAdapter(cmdLetyear)

Dim myDataSet As New DataSet
adpLetyear.Fill(myDataSet, "Yrlet")

gvletting.DataSource = myDataSet
gvletting.DataBind()
End If

End Sub
 
1) why dont you use required field validator control...

2) do you have autopostback set to true for your dropdown control?

3) use this condition inside your button click event...
if not page.ispostback then

end if

-DNG
 
Thank you for reminding me I will use required field validator control. thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top