473,545 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox and postback

Please help me with a listbox and postback issue that has me baffled. I am
storing my database connection strings in my web.config. At page_load, the
db strings that are currently stored in the file are displayed in a listbox.
This works as expected. Upon selection of a listbox item, the server name
and connection string are to be retrieved and placed into two textboxes for
edit or deletion. This is where my problem begins. The
SelectedIndex_C hanged event begins its process. However, after the page_load
method ends the code stops executing. The next batch of code that should
run, the code in the SelectedIndex_C hanged event, is not executed. I can see
this using breakpoints. The relevant code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
FillServerList( )
lboServerList.S electedIndex = -1
End If
End Sub
Public Sub FillServerList( )
Dim myServer As New DBServer
Dim sc As DBServerCollect ion
sc = GetServers()
For Each myServer In sc
Dim tNode As XmlNode
tNode = myServer.Server String
Dim nAttr As XmlAttribute
nAttr = tNode.Attribute s("ServerName ")
lboServerList.I tems.Add(DBStrD ecrypt(nAttr.In nerXml))
Next
End Sub
Private Sub lboServerList_S electedIndexCha nged(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
lboServerList.S electedIndexCha nged
Get the servers collection again.
Find the server based upon the selected index.
decrypt the selected server's name and connection string.
put the results in the text boxes and in session variables to be used later.
do some housekeeping.
End Sub
Please note that I am able to add a new server and the application
functions as it should. That is, the server data entered is encrypted and
stored in the web.config file and the listbox is updated with the new server
name. It’s only selection of a listbox item, causing a SelectedIndex_C hanged
event, that causes a problem.

Note also that the code for this web form is part is part of a web user
control. This control is then put into a placeholder when the page is built
at runtime. Your expert advice would be appreciated.

mark[No_Spam]pe*****@yahoo.c om

-Mark
Nov 21 '05 #1
0 1018

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4027
by: Irene | last post by:
I'm developing a Web application where a user selects from a listbox which can have many items. The initial display only shows about 10 items. After a postback, the listbox is automatically scrolled back to the top, so the selected item is mostly no longer visible. How can I keep the position, so that the selected item is still shown?
1
2176
by: chambersdon | last post by:
I have created a Web Custom Control that inherits from WebControls.ListBox but can't get it to retain the selectedIndex after a postback. As a test I created a very simple version of the control with no additional code. I just inherited from the exisiting ListBox class and put the control on a page. I put this control a blank page along...
6
6497
by: Valerian John | last post by:
I have a ListBox webcontrol on an aspx page. Items are added to the ListBox using client-side code. However, when the page is posted back the items are missing/not available. (It is like the page does not know the items were added client-side.) TIA, Val
8
2343
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the event. I do have EnableViewState = True for the listbox. I'm imagining (wanting) to populate the listbox named: lstNames by using the DataValueField...
10
3276
by: Adam Clauss | last post by:
I have a page containing a list box. This list may contain duplicate items - in which the ORDER is important. ex: a b b a is significant as compared to: b
9
3205
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback). This listbox has AutoPostback = True. When the user selects an item from this list, the second listbox is populated with more items relevant to this...
7
5583
by: Lit | last post by:
Hi, How can I capture the vertical scroll bar position for a Listbox. I have a Listbox of 100 items + when I click on it I post back remove the item selected. After returning to the client browser the list box scroll position is at the top.
1
3656
by: divya | last post by:
Hello, I used the below code to move selected items between two listboxes Left and Right:- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPopup.aspx.cs" Inherits="TestPopup" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
0
1818
by: Mel | last post by:
On Oct 23, 8:30 am, bruce barker <nos...@nospam.comwrote: Huh? Did you mean Listbox not DropDownList? The drop-down is working fine, it's the Listbox data that gets cleared after the drop-down list causes the postback.
15
2344
by: Doogie | last post by:
I have a .net app that a user currently enters a number in a text box, hits a button and a data call is executed. She wants the ability to enter in multiple numbers (up to 100). So to make things look better visually for that, I created a listbox under the text box. She enters the number in the text box, clicks another button I added and...
0
7468
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...
0
7401
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...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7423
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...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
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...
0
3443
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1884
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
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.