C# - .net DropDownList Gets Cleared After Postback?

Jul 8, 2010

This has been driving me nuts all day. I've seen this problem crop up here a few times, essentially I have a drop down list that populates a form below when it's changed - basic stuff. On first page load everything is fine, but when the dropdownlist is changed, it's entirely blank after postback and the SelectedIndexChanged event never fires. I believe it all points to a viewstate problem. Here's the code..

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="EditUser.ascx.cs" Inherits="Controls_EditUser" %>
<asp:DropDownList OnSelectedIndexChanged="SelectedIndexChanged" AutoPostBack="true" ID="UsersList" EnableViewState="true"
runat="server" DataTextField="EXTRANET_USER_EMAIL" DataValueField="EXTRANET_USER_ID">

[Code]....

View 2 Replies


Similar Messages:

Data Controls :: DropDownList Values Getting Cleared After PostBack

Nov 28, 2012

In my web application i am setting the EnableViewState="false" for particuler page. In that page i am having two dropdowns,this dropdown binding the data in Page_Load event. So when i am clicking the button that two dropdown values are getting celared. see the below sample code.

<%@ Page Title="" Language="C#" MasterPageFile="~/MobileMaster.master" AutoEventWireup="true"
CodeFile="ViewMapTag.aspx.cs" Inherits="ViewMapTag" EnableViewState="false" %>

<asp:DropDownList ID="ddlHashTag" EnableViewState="true"
runat="server">
</asp:DropDownList>
[CODE]...

View 1 Replies

AJAX :: CalendarExtender Cleared After Postback?

Mar 18, 2011

i desinged an page with updatepanel within that i used ajaxcalendarExtender control. now i selects the date after that click on the button based on this date then the application will read the data from the database and bind into the GV. but after this postback the calendar get cleared. i checked my page there is no place i cleared this date. but i dont know why this date has cleared. below is my code

<asp:TextBox ID="txt1" runat="server" Width="80px" CssClass="searchtext" ReadOnly="true" />
<img id="img1" src="datePic.gif" title="Date" height="20px" />
<ajaxToolkit:CalendarExtender ID="cal1" runat="server" PopupButtonID="img1" CssClass="AjaxCalendar" TargetControlID="txt1" />
<asp:CustomValidator ID="dateValidator" runat="server"></asp:CustomValidator>

View 1 Replies

Web Forms :: Textbox Data Is Cleared On Postback?

Dec 6, 2010

have a change password form ..It has 3 textboxes in it ..There are corresponding 3 required field validators ..When i enter value in these textboxes and press submit button data in these textboxes are cleared ..I want these values to be retained by the textboxes ..How to do?
[Code]....

View 1 Replies

Web Forms :: Prevent ReadOnly TextBox Value Getting Cleared On Page Postback?

Dec 21, 2012

I have a textbox of read only type with jquery datepicker so when the page post backs then that textbox value gets cleared. I do not want the textbox value to get clear but at the same time i need postback the page also..

View 1 Replies

Data Controls :: Dynamic Controls Created On Button Click Get Cleared On PostBack

Jun 15, 2013

I have created a web form in which i have used user control there is linkĀ  button on different link button user control loads . i have added dynamically webcontrol to that link button . they are loading properly but when i try to save data through one of user control on click of button the user control disapper from that place but when i put static user control to my page its working

View 1 Replies

Web Forms :: Disable Postback When Select Dropdownlist To Control Other Two Dropdownlist Value

Mar 25, 2011

I had use a combox to let user select staff name and then it will automatically retrive the responsible recommending officer and approving officer to display in other 2 dropdownlist.

my code works fine but when user select staff name each time, the page will reload once to refresh the dropdownlist.

user complaint and don't want the page reload every time, how can i disable the postback? I need to use ajax?

[Code]....

[Code]....

View 5 Replies

C# - Cascading Dropdownlist Without Postback?

Aug 10, 2010

I have a .aspx page having two dropdowns, the data to be loaded in them is usually static(but may change everyday), the first dropdown always displays the main categories and the second dropdown is initially empty.

Now, the requirement is:

As the user selects a category from the first dropdownlist, the second dropdownlist should populate based on the selection just made.

The road-block:

This should be done without a postback. My boss wants something like the drop downs on this page.

So what I gather is, I'd have to retrieve the data from the database on page load event, store it in the cache(or somewhere else?), then use javascript to handle the selectedindexchanged event of the 1st dropdown, use the data from database stored at pageload and populate the second dropdown according to the selected value of first dropdown.

P.S.- I'm a beginner ASP.Net C# programmer and have no knowledge of Javascript.

View 2 Replies

DropDownList Empty After Postback?

Aug 26, 2010

I'm working on ASP.NET 4.0 and I'm having problems for saving the selected value in a DropDownList.

I initialize it in the Web Control's PreRender method as follows:

if (!Page.IsPostBack)
LoadCountryList();

Where LoadCountryList's code is:

private void LoadCountryList()
{
var vr = new CountryRepository();
var countryList = vr.GetAllForList();
DdlCountry.EnableViewState = true;
DdlCountry.DataValueField = "code";
DdlCountry.DataTextField = "name";
dlCountry.DataSource = countryList;
DdlCountry.DataBind();
}

After I submit the form, I've noticed the DropDownList is empty(it's not before postback). If you take a look at my code, I've enabled the ViewState for this control, but I'm not getting any results yet. Does anybody know what's going on?

EDIT:

Here is the simple code of the control in the aspx file:

<asp:DropDownList Runat="server" ID="DdlCountry">
</asp:DropDownList>

View 3 Replies

DropDownList Empty On Postback?

Dec 2, 2010

I've looked at answers to some similar question but I still can't seem to figure this out. I think I'm misunderstanding something about how ASP.NET works.In the standard ASP.Net 4.0 'Create a new Account' form, I've added a DropDownList containing Roles to be selected for the new account. in the aspx page, the control looks like this:

<asp:DropDownList ID="RoleList" Width="100px" runat="server"></asp:DropDownList>

I am then populating the List in the Page_Load Event:

protected void Page_Load(object sender, EventArgs e)
{
RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"];

[code]....

View 3 Replies

ASPXAUTH Authentication Cookie Not Cleared On Sign/log Out

Dec 8, 2010

I'm using ASP authentication and the integrated webservice.

The user logins in with Forms authentication on a login page.

To log out, I call the authentication webservice from Silverlight and call logout.

Everything worked OK but now sometimes IE gets crazy and doesn't log out the user anymore.

I used Fiddler and it turns out that the authentication service returns a SetCookie to clear the ASPXAUTH cookie but on the next call IE still has the cookie set.

So off course because the cookie is there the user is authenticated and logs right back in rather than being directed to the login page.

I checked and didn't see any other description of the issue.

I can't reproduce it and my colleagues that have a misbehaving IE have it working fine on one environment and not on the other (one has the issue for DEV and another has the issue for the PreProd server).

View 2 Replies

Certain Fields Are Being Cleared When Other Updatepanel Events Occur?

Mar 25, 2010

I have the following within an updatepanel. If i make a selection somewhere else that has its own updatepanel, this data gets cleared.

[Code]....

What am i doing wrong? each updatepanel has its own trigger assigned to it.. so why would updatepanel#1 trigger cause updatepanel #7 to post and cause the field to clear? Even if i tab out of the textbox before completing it, causes the field to clear..

View 3 Replies

Security :: Fields Not Cleared After Creating New User?

Nov 11, 2010

I have a wizard control with 3 wizard steps. 1 contains "create new user", 2 for user management grid control and 3 for another functionalities.My problem is.. I am able to create new user successfully and after clicking on continue button in create new user, the name, email id text fields are not getting cleared.

View 7 Replies

Web Forms :: DropDownList Not Keeping Last Value On PostBack?

Apr 6, 2010

This would be a simple one for me if I was binding this dynamically. I don't think it's necessary to have a code behind for only 4 or so values. Anyways here is my ddl.

[Code]....

The problem is that when a user selects a value and it postbacks my ddl resets to the first value. How do I prevent this?

View 8 Replies

Web Forms :: Five Dropdownlist - How To Avoid Postback

Aug 3, 2010

I have 5 dropdpwnlist in asp.net page.. the 5th dropdwpnlist will show data based on 4th dropdownlist. and 4th dropdwpnlist will show data based on 3rd dropdownlist. and 3rd dropdwpnlist will show data based on 2nd dropdownlist. and 2th dropdwpnlist will show data based on 1st dropdownlist... All dropdownlist has auto postback=true.. so it cause postaback each time.. i want to avoid postback coz it refresh all page again and again and shows data.. coz my aplication is in hosting server..

View 5 Replies

Web Forms :: How To Keep The Colour In Dropdownlist After Postback

Nov 12, 2010

I created a dropdwonlist and add colours to the items. But the colours will lose after the postback. After googled, I knew it is because the attributes specified for the dropdownlist were not saved in ViewState and also found the code to Overriding SaveViewState() and LoadViewState(object) from [URL]

But after I copy the code to my web application to create a new class, there are so many error massages. I have spend two days to find the solution, without much success.

View 12 Replies

Can Fill Textboxes Using Dropdownlist Without Postback?

Feb 15, 2011

This is fine with a single textbox, but I want show different value from database into different textboxes.

How can I do that?

View 1 Replies

Web Forms :: Reset DropDownList After PostBack

Apr 1, 2010

I have a situation where i want to postback and redirect the user to the diffterent page wherever the user selects something from dropdown list. If the user presses the back button the in the browser the dropdownlist should be in the default state. i have already tried this code

protected void ddl_SelectedIndexChanged(object sender,Eventargs e)
{
int selecteditem = int.Parse(ddl4.SelectedItem.Value.ToString());
ddl.ClearSelection(
ddl.Dispose();
//Even tried ddl.selectedindex = -1 ;
//dosome postback i.e redirecting the user depeneding upon the value in selecteditem
}

View 8 Replies

Dropdownlist Doesn't Postback After Page_ClientValidate()?

Jan 18, 2010

I have just found the solution. The following function works (remove the else part):

function confirmSubmit() {
if (Page_ClientValidate("Group1")) {
return window.confirm("Are you sure to submit the form?");
}
}

But I am wondering why it doesn't work when I add the else part.

Question:

I want to have a confirm dialog after user fills in all the data in the form. I set onclientclick="return confirmSubmit()" in the submit button.

function confirmSubmit() {
if (Page_ClientValidate("Group1")) {
return window.confirm("Are you sure to submit the form?");
} else {
return false;
}
}

If Page_ClientValidate("Group1") returns false, the dropdownlist doesn't cause postback after I first select the item, and the postback only occurs when I select the dropdownlist second time.

View 1 Replies

Web Forms :: Expand DropDownList After Postback?

Mar 1, 2011

I would like to expand dropdownlist after onfocus postback. There is some code that runs when OnFocus is fired off then it needs to stay expanded so the user can select an item from dropdownlist. Currently it expands and contracts real fast when user clicks the dropdownlist, then the user has to click it again to select an item.

View 2 Replies

Web Forms :: Dropdownlist Not Refreshing After Postback?

May 10, 2010

I am having trouble with a dropdownlist and it's values not getting updated after postbacks.

Situation: I have an ASPX page that contains 2 user controls (UC1 and UC2). When the page first loads, controls on both UCs are set properly. My problem comes from the fact that when a dropdownlist on UC1 is changed, I need to reload a dropdownlist on UC2 (based on
the new value). I am raising an event from UC1 to the parent page when the dropdownlist value is changed and inside this method I am telling UC2 to reload it's dropdownlist based on the new value. When stepping through the sequence of events using the debugger, the values in the datatables and dropdownlists (item count) are 100% correct but after running through the logic, the dropdownlist on the page still has it's old values.

The initial values for the dropdownlist in UC2 are populated in Page_Load of the ASPX page, and nothing is done to the dropdownlist in Page_Load (!Page.Postback) of either the ASPX page or UC2. The only way I would like the values to change is when the event from UC1 is raised back to the page.

I have found a couple of other forum posts out there that had the same problem but I've tried those resolutions and nothing has worked. In the following examples, the value dt is the 'new' datatable that I wish to bind to the dropdown.I read that before rebinding the dropdownlist, that the Items need to be cleared and the SelectedValue should be set to NULL:

this.dropdownlist.DataSource = dt;

this.dropdownlist.Items.Clear();

this.dropdownlist.SelectedValue =[code]....

View 3 Replies

Web Forms :: DropDownList Doesn't Postback?

Sep 22, 2010

I've created two datasources, one that gets a list of categories and it's id's and the other one get subcategories and it's id's. The categories are presented in a DropDownList and the subcategories in a ListBox. When choosing a category from the DropDownList the ListBox presents the subcategories of the chosen category. The subcategory datasource is set to get it's value for what category to get from the DropDownList's selected value.

My problem is that when I change the category in the DropDownList the subcategories doesn't update on a postback. Instead I have to press a button on the page that I know performs a postback to get the subcategories to update. What am I doing wrong here? I'm using this method on another page as well and when comparing them I can't find anything different. Any ideas?

View 5 Replies

Web Forms :: Clear DropDownList On Postback?

Nov 29, 2010

i have two radio button list on my page on my Frist Index there is a panel with Drop Down List and on Second Index there is a static variable in which i am storing value as Pending

now as soon as i select my Second RadioButtonList it also stores the DropDown List Value

how i can clear the DropDown List Value?

My Code

[Code]....

My Page Source

[Code]....

View 6 Replies

Fill Textboxes Using Dropdownlist Without Postback?

Mar 28, 2011

I have an asp.net dropDownList listing hours and minutes of the day. I want the time chosen to be shown in a texbox. Can this be done without making a postback?

View 4 Replies

Web Forms :: Stop PostBack In DropDownList?

Oct 19, 2010

I hve few values in my Drop Down List

[Code]....

i want when ever i Select the Value-"Select " it should not postback it PostBack me when ever i Select the value ("Select Again")

can't use Ajax right now other alternative would be javascript

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved