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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DropDownList

Status
Not open for further replies.

vituja

Programmer
Oct 1, 2003
30
US
Hi,

I'm new to ASP.NET. I have a simple page with two controls (datagrid and dropdown box). The dropdown has a 4 digit year while the grid displays data depending on the year.

When the dropdown selection changes, I need the selected year to fire.


Here is the code I have but on the first selected value in the dropdown box fires:


Dim sqlConn As New SqlConnection("Data Source=dev2;uid=111;pwd=111;database=cunet_db") 'OleDbConnection
'open the connection
sqlConn.Open()


Dim YearComm As New SqlCommand("SELECT distinct(Year) FROM Holiday_tbl order by Year Desc", sqlConn)
'Populate the dropdown box with all sorted years
Dim YR As SqlDataReader = YearComm.ExecuteReader()
While YR.Read()
YearList.Items.Add(YR("Year"))
End While
YR.Close()

'create the command object to bring back all the valid holidays for selected year
Dim sqlComm As New SqlCommand("SELECT Value as Date,Type as Description FROM Holiday_tbl where year=" & YearList.SelectedValue & " order BY year,Month,Day", sqlConn)

Dim r As SqlDataReader = sqlComm.ExecuteReader(CommandBehavior.CloseConnection)
myDataGrid.DataSource = r
myDataGrid.DataBind()

r.Close()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top