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


Similar Messages:

Web Forms :: DropDownList Not Refreshing Despite DataBind

Jan 12, 2011

This is my setup: I've got a dropdownlist of people and a linkbutton next to it to add a person. the linkbutton makes an update panel appear. When clicking save, I want the data to be saved and the new person be selected in the dropdown. As far as I can tell, I have done this properly. After I save the data I refresh the dropdownlist and take the new person's value and set it as the selected value. When stepping through, it shows the ddl with the new person and the new person selected! BUT, when the page comes back, the ddl is unchanged, ie NOT refreshed. I thought it might be something with the Update Panel but I got a similar setup to work on another page! It also works on a nested Update Panel (not shown in the following code). Can you think of why this "deception" is happening?

Here is some of my code.

[Code]....

View 5 Replies

Web Forms :: Stop Refreshing Dropdownlist Without Update Panel?

Mar 8, 2010

I have a data grid and and bind a column a Dropdownlist. when i select the Item of Dropdown list the page is Refrehed. How can i stop this. I dont want use Update panal.

View 2 Replies

AJAX :: Refreshing Update Panel Through Javascript Postback?

Mar 17, 2010

In one of my webpage, I have a parent window where i have a datalist with 10 rows of images. when i click any image a pop up window(child window) opens.

The child window has a form to be filled by user. Once user fills this form, he will press the save button. Once the save button is clicked, the child window should be closed and the datalist(in the update panel) in the parent window should be refreshed.

This is how I am trying to achieve this. On click of the save button a javascript function is being called of the parent window like this: window.opener.refreshDataList();

in the refreshDataList() function I have written the following code:

{
childWindow.close();
__doPostBack('ctl00_ContentPlaceHolder1_UpdatePanel1', '');
}

This works like a charm in Internet Explorer. However in Mozilla and Chrome it doesnt work. While testing this I added an alert statement ind the refreshDataList() function like this..

{
childWindow.close();
alert("Testing");
__doPostBack('ctl00_ContentPlaceHolder1_UpdatePanel1', '');
}

Once I added the alert statement, It started working in both mozilla and chrome.

So I realize that It could be an issue related to focus. I have done window.focus()

but still its not recieving any focus and not working in Mozilla and Chrome.

View 2 Replies

State Management :: Postback Not Refreshing Datasource - How To Refresh It

Apr 27, 2010

I have a linkbutton that displays a different record each time the page is loaded. When I first bring the page up, I can hit F5 repeatedly and the linkbutton works properly rendering a diff record each time. But in a dropdown list, or any other control that causes a postback, the linkbutton remains static, why?

In my Page_load I have

AccessDataSource1.SelectCommand = "SELECT blah FROM table where trim(recid)=" &
"'" & rndVal &
"'"
AccessDataSource1.DataBind()
LinkButton1.Text = DetailsView1.Rows(0).Cells(1).Text

View 7 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

Data Controls :: Filter Repeater Records Based On DropDownList Selection Without Refreshing Page

Jul 17, 2015

I have repeater control on page which bind with sql data source.i have dropdown to filter the records of repeater on button click event it refresh complete page i just want to show a wait message to user and just refresh repeater data instead of complete page refresh.i do not want to use ajax update panel.

View 1 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

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

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 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

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

Web Forms :: Refreshing Client Web Page Upon Refreshing Server Web Page?

Mar 4, 2010

I have a requirement where a user logs on to a server where exists a website. The user bring up the site on a browser on that server and loads a power point presentation slide. At that time, users using their laptop clicks on the link to that site and sees that particular PPT slide loaded on the server. Then the operator/user on the server clicks on the second slide and the laptop would now see the second slide. Is this possible to do? If yes, then what technology to use? DHTML? or something else.

View 4 Replies

Web Forms :: How To Maintain DropDownList Styling After Postback

Feb 25, 2010

Using VS2008, .NET 3.5, and C#. The page contains (among other things) a dropdownlist and an objectdatasource. The Page_Load event fires the objectdatasource's Select event. The Selected event iterates through the returned datatable, feed each row into a ListItem, checks to see if a certain column is True or False and, if true, changes the styling for that row to color:red. Finally, the listitem is bound to the dropdownlist. The end users sees all of the dropdownlist items that are false in black and the items that are true are in red. Works perfectly. However, as soon as any item is selected, the page does a postback and the font colors in the dropdownlist revert to the default black. Is there a way, other than rerunning the method that iterates through table and creates the listitems, of maintaining the coloration of the items? Is there a ViewState setting or something?

Here is the dropdownlist and objectdatasource's Selected event:

[Code]....

[Code]....

View 3 Replies

Web Forms :: Dropdownlist Onchange With Confirm Does Not Postback

Mar 10, 2010

i have dropdownlist with autopostback=true,

written onchange event for confirm popup and SelectedIndexChanged event also exists.

req is if confirm returns true then only postback should happen else not

instead its not atall doing postback whether it returns true or false.

i managed to get it work by forcing postback by using __doPostback()

View 13 Replies

Web Forms :: Unable To Get Dropdownlist Control Value At Postback?

Feb 23, 2010

I have 2 - DropdownList controls, which i am filling at severside when page loads. After the user selection in DropdownList1, i am changing the contents in DropdownList2 values. This validation (i.e. changing the contents of Dropdownlist2 values) am doing in Javascript Clientside. But on postback i am not getting the values in DropdownList2. When i say "DropdownList2.Items.Count;" getting "0". I tried to put the contents of DropdownList2 in ViewState on pageload. But i am getting Serialization error at runtime "Viewstate["PersistValues"] = DropdownList2;". I am using html input hidden control to pass the values from server side to clientside for my validation. Now, to meet this requirement i am Binding the DropdownList2 at postback again with first DropdownList1's selected index (This is repeat of logic which i have done in Clientside).

View 5 Replies

Web Forms :: Dropdownlist Selection Changes To First Item On Postback

Oct 19, 2010

I have been having some trouble with dropdown lists reverting back to selecting the initial item in the list after a postback once a selection has been made from the dropdown list. I have read up on this and found out that a "if not ispostback then" is required.This works fine when I add in all the items in the dropdown list manually like:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
ddl1.Items.Add("Select...") [code]....

However, I have over 250 items and so it is far more efficient for me to load then in by using part of a multidimensional array which is created from a text file - Definitive database.txt. I have been using the following code to do so:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
'loads the definitive database array[code]...

This loads all the items into the dropdown list perfectly, but now every time a selection is made, it reverts back to the inital item on postback even though i have included the "if not ispostback then" part.

View 3 Replies

Web Forms :: DropDownList Causing Postback On Change

May 9, 2012

I have 1Dropdownlist 1 button and 1 datalist in my page i bind my datalist in Page_load event that show all my product from my DB ... Users  can select their city from DDL click on button and in datalist just show product that are on selected city ...

Problem: when users select PARIS from ddl in datalist show product from selected city and when users want change their city from ddl before their click on button to show that city's product page load again and it show all product again...

I want when users change ddl.selecteditem in datalist show last result of user's selected not the result that i define in page load ... This is my code on page load ...

  protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
DDLcity1.Items.Add(new ListItem("select your city", ""));
BindDropDownList(DDLcity1, "Guidcity", "cityname", "ID");
}

View 1 Replies

How To Prevent Dropdownlist From "refreshing" When Another Button Is Clicked

Jun 17, 2010

I have a simple vb.net page. The first control on the page is a dropdownlist that the user selects from. The second is a text box with a search button. When search is clicked, a third control (another dropdownbox) is populated. BUT, whenever that search button is clicked, the first dropdownbox seems to refresh, and I loose the selection that the user made.

View 1 Replies

Web Forms :: DropdownList Selected Value Clear (lost) After Every Postback

Feb 25, 2016

I have the problem with dropdownlist value inside gridview.my problem is i have textbox,button with two dropdownlists, dropdownlists are inside gridview.Two dropdownlists are  one is ddlcountry and another one is ddlstates. if i select  country from ddlcountry , country related states comes in ddlstates. after entering  first record value in textbox then button click  textbox value is shown in gridview with two dropdown lists dropdown list, after selecting one dropdownlist country and states, i enter second record value and button click then only country selected value visible ddlstates selectedvalue not visible in first record in gridview...

View 1 Replies

Web Forms :: How To Pass Selected Value Of DropdownList To A User Control On Postback

Feb 25, 2010

I need to create a user control which will be loaded according to the selected value of a dropdownlist. The Dropdownlist is not the part of Control. I want to pass the value of selected value of dropdonwlist to my user control and the user control will load according to the Value. For not postback it work fine. But when the page is postback, that is when i select a item form dorpdownlist, the user control is not loaded.

View 6 Replies

Forms Data Controls :: Dropdownlist Postback Always Select First Item?

Mar 24, 2010

I have 2 dropdownlist controls (ddl1 and ddl2). When I pick an item from ddl1, it will update ddl2. The problem is when I pick an item in ddl2, it always selects the first item in the list. Is it that the ddl2 autopostback causes the first ddl1 to reload and results the ddl2 to be refreshed also? Or I didn't set something correctly?

[Code]...

View 12 Replies







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