can someone tell me why the selected item won't reflect user change in this
little droplist example
<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
mydropdown.Item s.clear
mydropdown.Item s.Add( New ListItem( "alpha", "alpha" ))
mydropdown.Item s.Add( New ListItem( "beta", "beta" ))
mydropdown.Item s.Add( New ListItem( "gamma", "gamma" ))
End Sub
Sub Select_Click(By Val sender As Object, ByVal e As EventArgs)
Messagex.text &= " selected = "
Messagex.text &= mydropdown.Sele ctedIndex
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<table cellspacing="0" cellpadding="0" width="50%" border="0">
<tbody>
<tr valign="center" >
<td align="left" width="100%">
<span>Select&nb sp;:</span>
</td>
<td align="left" width="100%">
<asp:DropDownLi st id="mydropdown " runat="server"
enableviewstate ="true"></asp:DropDownLis t>
</td>
<td align="left" width="100%">
<asp:Button id="btnSelect" onclick="Select _Click"
runat="server" CausesValidatio n="False" Text="GO"></asp:Button>
</td>
</tr>
<tr valign="center" >
<td align="left" width="100%">
<br />
<asp:Label id="Messagex" runat="server"
enableviewstate ="true" forecolor="red" width="80%"></asp:Label></td>
</tr>
</tbody>
</table>
</form>
</body>
</html> 1 1769
when the user clicks the button, Page_Load fires first, thus clearing the
dropdownlist and re-adding the listitems...
If Not PAge.IsPostBack then
mydropdown.Item s.Add( New ListItem( "alpha", "alpha" ))
mydropdown.Item s.Add( New ListItem( "beta", "beta" ))
mydropdown.Item s.Add( New ListItem( "gamma", "gamma" ))
end if
Karl
"TJS" <no****@here.co m> wrote in message
news:eD******** ******@TK2MSFTN GP12.phx.gbl... can someone tell me why the selected item won't reflect user change in
this little droplist example <%@ Page Language="VB" %> <script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
mydropdown.Item s.clear mydropdown.Item s.Add( New ListItem( "alpha", "alpha" )) mydropdown.Item s.Add( New ListItem( "beta", "beta" )) mydropdown.Item s.Add( New ListItem( "gamma", "gamma" ))
End Sub
Sub Select_Click(By Val sender As Object, ByVal e As EventArgs)
Messagex.text &= " selected = " Messagex.text &= mydropdown.Sele ctedIndex
End Sub
</script> <html> <head> </head> <body> <form runat="server">
<table cellspacing="0" cellpadding="0" width="50%" border="0"> <tbody> <tr valign="center" > <td align="left" width="100%"> <span>Select&nb sp;:</span> </td> <td align="left" width="100%"> <asp:DropDownLi st id="mydropdown " runat="server" enableviewstate ="true"></asp:DropDownLis t> </td> <td align="left" width="100%"> <asp:Button id="btnSelect" onclick="Select _Click" runat="server" CausesValidatio n="False" Text="GO"></asp:Button> </td> </tr> <tr valign="center" > <td align="left" width="100%"> <br /> <asp:Label id="Messagex" runat="server" enableviewstate ="true" forecolor="red" width="80%"></asp:Label></td> </tr> </tbody> </table> </form>
</body> </html> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Aaron Prohaska |
last post by:
I'm having the problem with this drop down list on postback. For some
reason both the ListItems get selected when I change the selected item.
Using the code below I'm building the drop down list in the overriden
CreateChildControls method and setting the selected item. Then when I
change the item in the drop down list the list is rebuilt from
viewstate, but the initial item is still selected causing the error
below.
I also have a number...
|
by: dhnriverside |
last post by:
Hi guys
Still having a problem with this dropdownlist.
Basically, I've got 4. The first 2 work fine, then my code crashes on the
3rd.
ddlEndTimeHour.Items.FindByValue(endTime).Selected = true;
Where endTime is a string containing "15".
|
by: Karen Grube |
last post by:
Hi!
I'm using a standard server side ASP.Net listbox control on a web form.
The page is basically various shades of green. The listbox itself has a pale
green background and forest green text and a forest green border. However,
when you move the cursor from one item to the next within the listbox or you
click on an item in the listbox to select it, the background turns to the
standard windows dark blue with white letters. Well, that...
|
by: Brian Henry |
last post by:
say I have a databound combo box, which allows for text entry still
(DropDownStype = DropDown in this case).
now, If the user doesn't enter manually an item in the data bound list,
nothing should be selected of course, but I want if a user enters an item
that is in the list already, to select it, and only if the item is a
complete match to what they typed to be selected. This is kind of like an
auto complete scenerio, but allows for...
|
by: Dick |
last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls
GridView.DataBind. I want the row that is selected before the DataBind to
still be selected afterwards.
This happens automatically if the data doesn't change. But if records have
been added or deleted then it looks as if some code is necessary: I've done
this by using GridView.SelectedValue to get the key value of the currently
selected Row and then by itterating...
| |
by: Santosh |
last post by:
Dear all ,
i am writting following code.
if(Page.IsPostBack==false)
{
try
{
BindSectionDropDownlist();
|
by: Iain |
last post by:
Hi All
I have 2 DropDownList boxes on a page.
The first (id= "Operation") is populated on PageLoad with the contents
of a database table.
The second id="WorkStations" will not be populated until the first has
been changed
The definitions are below.
|
by: peter.mosley |
last post by:
I've tried googling for the answer to this problem, without any luck.
I'm sure the truth must be out there somewhere!
I have a multiselect listbox populated with many items (set by the
RowSource property). In my code I cause a number of these to be
selected - but if the first selected item is not within the currently
visible range then there is no change to the display. This gives the
impression that nothing has happened.
I think...
|
by: Geary |
last post by:
I have a drop down list on an asp.net 2 page that is bound to a table.
By default it displays the first item as the selected item. But I want
to make sure that the user must change the selection. I am using the
change-selection event to trigger so other code. If the user is
satisfied with the default this other code won't run. So I am adding an
additional .item.add("(None)") after the .databind() to add a (None)
selection to the list....
|
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...
|
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,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |