472,122 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,122 software developers and data experts.

dropdownbox Selecteditem

I've got a dropdownbox with a few values in it. There is one value that is selected in advance. But when I change the value in the dropdownbox to a larger amount and press "Search" the value that continues is the standard value.
Here is my code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.     FillList()
  3.     End Sub
  4.  
  5.     Private Sub FillList()
  6.         Dim oNewTable As HtmlTable
  7.         Dim oNewRow As HtmlTableRow
  8.         Dim oNewCell As HtmlTableCell
  9.     Dim oNewListItem As ListItem
  10.     Dim oNewImageButton As ImageButton
  11.     oNewRow = New HtmlTableRow
  12.     oNewCell = New HtmlTableCell
  13.     Dim i As Integer = 0
  14.     Dim iMonth(5) As Integer
  15.     iMonth(0) = 1
  16.     iMonth(1) = 3
  17.     iMonth(2) = 6
  18.     iMonth(3) = 12
  19.     iMonth(4) = 20
  20.  
  21.     While i < 5
  22.         If i=0 Then
  23.                 oNewListItem = New ListItem
  24.                 With oNewListItem
  25.                           .Value = iMonth(i)
  26.                            .Text = iMonth(i) &" month"
  27.                 End With
  28.             lstSales.Items.Add(oNewListItem)
  29.         Elseif i=4 Then
  30.                 oNewListItem = New ListItem
  31.                 With oNewListItem
  32.                            .Value = iMonth(i)
  33.                            .Text = "All"
  34.                 End With
  35.             lstSales.Items.Add(oNewListItem)
  36.         Else
  37.                 oNewListItem = New ListItem
  38.                 With oNewListItem
  39.                            .Value = iMonth(i)
  40.                            .Text = iMonth(i) &" months"
  41.                 End With
  42.             lstSales.Items.Add(oNewListItem)
  43.         End If
  44.         i+=1
  45.     End While
  46.     lstSales.Items(1).Selected = True
  47.  
  48.     End Sub
  49.  
  50.     Private Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
  51.      Response.Redirect("rptSalesProjectsGraph.aspx?ID=" & lstSales.SelectedItem.Value)
  52.     End Sub
  53.  
So 3 months is standard, but when I want to change is to, for example, 6 months it stays 3 months. But when I change it to 1 month it works perfectly.
May 25 '07 #1
0 983

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by thomas j | last post: by
1 post views Thread by Jim Heavey | last post: by
reply views Thread by Sunil Sabir | last post: by
4 posts views Thread by darrel | last post: by
2 posts views Thread by Lars Netzel | last post: by
reply views Thread by Danny M | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.