473,785 Members | 2,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Page loses values

I developed a webesite using c#. I have a dropdownlist wich is filled with
database values. When i click on a button on the same page all values are
lost in the dropdownlist.
The most common answer is to populate the ddl in "if !is postback" which i
did. When i debug it seems that before the postback all values are lost.

When i tried to do the same on my local machine (localhost) everything works
fine.

Can someone please help

regards
Ron
Nov 17 '05 #1
3 1584
hi

post some code, especially where you define the dropdown in the aspx file
and where you fill it and the load method

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Ron Wallegie" <wa******@hotma il.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I developed a webesite using c#. I have a dropdownlist wich is filled with
database values. When i click on a button on the same page all values are
lost in the dropdownlist.
The most common answer is to populate the ddl in "if !is postback" which i
did. When i debug it seems that before the postback all values are lost.

When i tried to do the same on my local machine (localhost) everything
works fine.

Can someone please help

regards
Ron

Nov 17 '05 #2
Thank for your reply!

I created an hashtable, which i use to fill my dropdownlist.
On my form i've got a dropdownlist, 1 button and a textfield.
When i click on the button, all values in my form (textbox and dropdownlist)
are lost!

Keep in mind that everything worked fine on my local machine and viewstate
is enabled.

Your help is much appreciated

Regards,
Ron

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;

namespace WebApplication1
{
/// <summary>
/// Summary description for WebForm2.
/// </summary>
public class WebForm2 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Text Box
TextBox1;
protected System.Web.UI.W ebControls.Butt on Button1;
protected System.Web.UI.W ebControls.Drop DownList
DropDownList1;

private void Page_Load(objec t sender,
System.EventArg s e)
{
if (!IsPostBack)
{
Hashtable myHash = new
Hashtable();
myHash.Add("1", "One");
myHash.Add("2", "Two");
myHash.Add("3", "Three");
myHash.Add("4", "Four");

foreach (DictionaryEntr y
myDE in myHash)
{
ListItem newLi =
new ListItem();
newLi.Text =
myDE.Value.ToSt ring();
newLi.Value =
myDE.Key.ToStri ng();
DropDownList1.I tems.Add(newLi) ;
}
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the
ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not
modify
/// the contents of this method with the code
editor.
/// </summary>
private void InitializeCompo nent()
{
this.Button1.Cl ick += new
System.EventHan dler(this.Butto n1_Click);
this.Load += new
System.EventHan dler(this.Page_ Load);

}
#endregion

private void Button1_Click(o bject sender,
System.EventArg s e)
{
TextBox1.Text =
DropDownList1.S electedValue;
}
}
}

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
hi

post some code, especially where you define the dropdown in the aspx file
and where you fill it and the load method

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Ron Wallegie" <wa******@hotma il.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I developed a webesite using c#. I have a dropdownlist wich is filled with
database values. When i click on a button on the same page all values are
lost in the dropdownlist.
The most common answer is to populate the ddl in "if !is postback" which
i did. When i debug it seems that before the postback all values are
lost.

When i tried to do the same on my local machine (localhost) everything
works fine.

Can someone please help

regards
Ron


Nov 17 '05 #3
Thx for you reply.
This is probarly what you wanted.
Regards,

Ron

<%@ Page language="c#" Codebehind="Web Form2.aspx.cs" AutoEventWireup ="false"
Inherits="WebAp plication1.WebF orm2" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm2 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<asp:DropDownLi st id="DropDownLis t1" style="Z-INDEX: 101; LEFT: 32px;
POSITION: absolute; TOP: 40px"
runat="server"> </asp:DropDownLis t>
<asp:TextBox id="TextBox1" style="Z-INDEX: 102; LEFT: 192px; POSITION:
absolute; TOP: 40px" runat="server"
Width="232px" Height="112px"> </asp:TextBox>
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 112px; POSITION:
absolute; TOP: 40px" runat="server"
Text="Button"></asp:Button>
</form>
</body>
</HTML>

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
hi

post some code, especially where you define the dropdown in the aspx file
and where you fill it and the load method

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Ron Wallegie" <wa******@hotma il.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I developed a webesite using c#. I have a dropdownlist wich is filled with
database values. When i click on a button on the same page all values are
lost in the dropdownlist.
The most common answer is to populate the ddl in "if !is postback" which
i did. When i debug it seems that before the postback all values are
lost.

When i tried to do the same on my local machine (localhost) everything
works fine.

Can someone please help

regards
Ron


Nov 17 '05 #4

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

Similar topics

0
1061
by: quique | last post by:
Hi I,m gonna explain my scenario problem: I've got an user control that i want to cache in diferent pages attending to the value of a parameter x, to make t possible i put the next directive in the definition of the control <%@ OutputCache Duration="50" VaryByParam="x"%> I,ve got two pages (page1in and page2in) that submits to
5
6935
by: Robert Phillips | last post by:
I have a Panel control containing a few TextBox controls. The Panel is originally enabled, I enter data into the TextBox controls. When I submit, the Panel is disabled during the PostBack and the TextBox controls render greyed-out, and I can see the values in the TextBox controls....this is what I expected. I submit again, the Panel is enabled during the PostBack. All of the TextBox controls within the Panel are now enabled, however,...
1
1191
by: Raheel Hussain | last post by:
hi, can any body tell me why the variable loses its value, i m actually declaring a variable which is public, and assigning a values in Function1 and reading the values in Function2 following is a sample code for wht i m doing. --------------------------------------- Public Class SupportRequest Inherits System.Web.UI.Page
4
1801
by: Mark Broadbent | last post by:
This one has got me absolutely stumped. At work I have created a simple web form that gets data from a sql backend and puts this to a dataset. I have an edit button that when clicked will set the relevant text properties of several textboxes (to allow for edit) ....all simple so far. I have a save button that when clicked will then perform the writing back of the text in the textboxes. The problem is (and having debugged I see this)...
1
573
by: Janaka | last post by:
Help! I have two ListBox controls on my web form. The first one gets populated on entry with values from the DB. I then use JavaScript to copy options from this ListBox to my second one. (I have also tried changing the second ListBox to an HtmlSelect control) using bog standard JavaScript code like so where "used" is the name of my <select> control: used.options = new Option(name, typeId); This all works fine and I can move across...
1
1537
by: Tom wilson | last post by:
Yes, I'm sorry, it's me again. :) Yesterday I went through hell trying to figure out why my aspx pages wouldn't maintain state. I had a simple example I (we) eventually got to work. What I've discovered is that my problem seems to lie entirely with IE. A bit of history... My app is an online survey. The questions, choices and so on are
7
1740
by: jvaradarajan | last post by:
I've an ASP page which generates 4 kinds of reports based on a selection from a dropdownlist. There is a dropdownlist, datagrid and a generate report button in the page. The page works fine in IE. But in firefox, it loses formatting. After loading the page, everytime I choose an item from the dropdownlist, the dropdownlists moves to the right and everytime the button gets pushed down slowly. But the datagrid remains in the same place. Is there...
1
3438
by: stimul8d | last post by:
okay; ASP. I have i listbox inside a user control which is dynamically created on page_init. I check for postback and only populate the datasource if it's false. regardless, i do this foreach (Product p in manager.Products) { ASP.MasterDetailDropDown productMasterDetail; productMasterDetail = (ASP.MasterDetailDropDown)LoadControl("~/controls/MasterDetailDropDown.ascx"); ...
8
3301
LacrosseB0ss
by: LacrosseB0ss | last post by:
Hey folks; I have PHP session variables that are having some troubles. I posted in a few other forums but couldn't really find one dedicated to my specific issue. I am using a few session variables throughout my website and am using the following two lines at the top of every session related page: <?php session_start(); $_SESSION = ""; //initialization on first page used only ?>
0
9647
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
9485
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
10356
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10161
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...
1
10098
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,...
1
7506
isladogs
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...
0
6743
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5390
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...
3
2890
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.