473,880 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dropdownbox Selecteditem

1 New Member
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 1030

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

Similar topics

6
2021
by: thomas j | last post by:
Hi, I have a MySqlBase with a tabel named CARS and with 3 fields; CarsType, CarsModel, CarsInfo. Now I want to generate 2 dropdownboxes in PHP read from CARS. First I will "load" CarsType into an dropdownbox, and then I make a choice, exampel FORD, now the next dropdownbox (CarsModel) will show Escort, Sierra and so... Finally I will make a "actionbutton" named showinfo and when I click it will show CarsInfo.
1
1227
by: Jim Heavey | last post by:
Hello I have a datagrid that has a footer that I have place a dropdownbox on and loaded the values in the datalist in the ItemCreated Event. Everything is just as I expected when the grid is presented. I select some value from the DropDownList and then press a command button, also on the footer. By the time I get to the event which handles the button click event (CommandName Property in the datagrid), the
0
968
by: Sunil Sabir | last post by:
Dear All, I have a web form which has a link and a drop down box. when I press a link a pop up window opens. This window has a lot of TEXTBOXES and a Save button. When I fill the TextBoxes and press save the POP UP window closes. Actually this POP UP window is a record of an employee. so basically I am filling the personal information of the employee. What I want is that when I press save Button the POP UP window must close. And It...
4
3480
by: darrel | last post by:
what is the difference between these? I always end up typing 'selectedvalue' only to have problems and then realize I meant to use selecteditem.value (the value of the selected item). When would one use the former (selectedValue)? -Darrel
2
1757
by: Lars Netzel | last post by:
Hi I'm having a DropDown box with 2 items... one with Value 1 and one with Value 2. If I load the page and it has Value 1 selected from page_load() and then select Value 2 on the form.. .and then from a checkbox use javascript to diasable to DropDownBox before I press a button to do the post back. So.. the DropDownBox has Value 2 but it manually disabled by me..
0
917
by: Danny M | last post by:
When i change the value in the dropdownbox. The value changes. When i check the datatable the value has changed But when i want to save it to the database the record didnt got a changed flag When i do dtTest = dtData.getchanges then dtTest is nothing ??? But still the value in the datatable has the right value, but because it didnt have a change flag it isnt saved to the database??? What i am doing wrong??
2
7095
by: Tracey | last post by:
How can I convert to a string (what I thought was a string)? and/or How can I assign the value of a selected item in a list box to Label1.Text? using VB in VS2005. Thanks, Tracey I completed a {simple} class project that displays the value of what was clicked in a List Box (which appears at the top of the page): Response.Write("You clicked ")
1
1163
by: iniyan | last post by:
hi guys need help again!!!! i want to retrieve data from the database table and put inside my drop down box.For example i want to view all my products example F216,F217,F218 in my dropdown box.how to do that?How to view all data in column in my dropdownbox.
1
1199
by: bujjai | last post by:
i am using dropdown box in gridview when form is loaded dropdownbox is dynamically bound .from the database... it should load the data how tell me urgent boss help me
0
9926
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9774
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10715
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10396
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5778
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5973
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4192
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3220
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.