Dropdown In .net Usercontrol Not Maintaining State
Nov 15, 2010
This is probably something fundamental and stupid that I've missed, but the various workarounds are causing me such huge headaches that really, I need to understand the basic problem here in order to find the best solution. I have a usercontrol which contains a drop-down list.
<asp:DropDownList ID="ddlOrderStatus" AutoPostBack="true" runat="server" CssClass="textbox">
<asp:ListItem value="8">Pending</asp:ListItem>
<asp:ListItem value="9">On Hold</asp:ListItem>
<asp:ListItem Value="11">Complete</asp:ListItem>
<asp:ListItem Value="12">Cancelled</asp:ListItem>
</asp:DropDownList>
It does nothing in its Page_Load event. This is in turn contained in a page which, in it's Page_Load event does some databinding on some repeater controls on the page but doesn't touch the control containing the ddl. There is no ajax on the page. The dropdownlist is - clearly - set to autopostback = true. The postback code looks like this:
Private Sub ddlOrderStatus_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlOrderStatus.SelectedIndexChanged
Dim ddl As DropDownList = DirectCast(sender, DropDownList)
Dim currentsorting As String = Request.QueryString("sort")
Dim currentpaging As String = Request.QueryString("page")
Response.Redirect(String.Format("~/admin/orders/Manage/0?sort={0}&page={1}&status={2}", currentsorting, currentpaging, ddl.SelectedValue))
End Sub................................
View 2 Replies
Similar Messages:
Feb 25, 2011
i have places a treeview in the master page, if i click on certain node it will navigate to some x.aspx page.here the proble is treview nodes all are collasped.
View 2 Replies
Jul 11, 2010
I have a website that returns search results from Twitter, written in C# ASP.NET. The search works very well.When the user sees the results I want them to also have a 'Next Page' type hyperlink that will perform the search from the last previous result onwards (using Twitter's next_page data). How can I preserve properties so that when a link is clicked it will run the search again with different parameters for the next results? I cannot use Form as there is one Form on the page already and MS limits to one Form per page (for runat="server")
View 3 Replies
Feb 26, 2010
I have a web page that regularly refreshes on post back, and all of this works fine. However, a user has made enhance the page, which I need with:
1) There are 3 asp.panels on the page, which are scrollable vertically. When the page refreshes, the scroll position returns to the top. The enhancement is to maintain the position of where ever the scrollbar is on postback. How do I keep the scrollbar position on post back?
2) Within each of the panels are dynamically added web controls. These web controls contain gridviews, which are themselves contained inside div tags. These div tags can be hiddened and made visible by an image button. This hidden and visible state is actioned by some javascript on the page. Again, the user has asked how it is possible to maintain the state of these div tags on post back, i.e. those that are closed and those that are visible. Currently, the state is on postback for all the div tags to be visible. How do I maintain the state of the visibility of a div tag during postback?
View 4 Replies
Nov 10, 2010
Bit confused about this. I was under the impression that if you added server controls to the ItemTemplate of a repeater then the ID's assigned to those controls would persist across postbacks and the state would be maintained. But it doesn't seem to be happening. Here's my ItemTemplate:
[Code]....
Which populates fine. What I'm looking to happen is for the user to be able to select certain items from the repeater using the checkbox and "process" them (i.e. perform some data operations on those items) on clicking a button which is outside the repeater. Here's my button click code:
[Code]....
But if you step through this, the checkboxes are found and assigned correctly but their Checked attribute is always False.
View 1 Replies
Aug 17, 2010
How to maintain selected CheckBoxes' states in different pages inside the Repeater control and list out the selected checkboxes values.
View 2 Replies
Jan 14, 2011
I have a gridview with results from a database query and columns where I add linkbuttons to individual cells.
something like:
Dim LB2 As New LinkButton
LB2.Text = "title"
LB2.CommandArgument = "argument"
AddHandler LB2.Click, AddressOf LaunchDocument
GridView1.Rows(i).Cells(10).Controls.Add(LB2)
There is a lot time involved in determining what cells get the linkbutton and I want to avoid going through that process on a postback when a user clicks one of the linkbuttons.How can I maintain these controls in the gridview after a user clicks a linkbutton and a postback is done?Right now the application has to go through the process all over again.
View 6 Replies
Feb 23, 2011
I had a webform, in which I included the ajax control toolkit. From that, I inserted the tab control on to my webform, having 4 tabs in that tabcontainer. So, I am allowing the end user to enter the information in the first 3 tab panels, and want to display the entered info on the 4 tab panel, which shows all the info entered in the 3 tab panels.
So, how should I manage the information, and display the entered information on the 4th tab panel.. I had some plans of implementing an accordian ajax control for each 3 tabs info, allowing the user to edit at the 4th tab itself..Is this the right idea, or else suggest me, how to display the all the entered info in the 4th tab,like can i use details view, or grid,or suggest something else!!! I added a button to each panel, so that after the user enters the information, he will be redireted to the next tab panel after firing the "Save and continue" button.
AFter the user confirms the data on the 4th tab panel, and presses the submit button, then the entered info has to be entered into the database, for this to happen,. whtat should i do...??Can you plz help me out with some detailed explanation, as I am newbie , need support from you kind of ppl...In the first tab, I had some 4 text boxes, and 3 dropdowns, and a save and continue buttton, and in the next panel, some more text
just give me helping hand, by hinting..
View 2 Replies
Aug 5, 2010
I am using Cascade dropdown the basic code which i used write down below i am reading data from xml file for Country,State,City.before sometime it was work fine but now it give me an "undefined" data in state dropdown only.
Basically i make a user control on this page my design code are as follow
[Code]....
and on one aspx page i call this control and put a one webmethod for state dropdown
[Code]....
View 1 Replies
Sep 25, 2010
I have a scenario where I need 2 dropdowns like state and city.City dropdown depands upon on State drop down.Will you please tell me how to achieve it ASP.NET MVC?I found this article but not sure is there any alternate way to do?http://stephenwalther.com/blog/archive/2008/09/07/asp-net-mvc-tip-41-creating-cascading-dropdown-lists-with-ajax.aspx
View 1 Replies
Feb 6, 2010
Here is what I am trying to do. I have a page with two link buttons and an updatepanel (the two linkbuttons trigger the updatepanel). I have two usercontrols which have labels with same ID's. When I click the first link button, I add the first usercontrol to the updatepanel and set the label value to datetime.now
when i click the second link button i add the second usercontrol but i see that the value of the label from the first control is set in the label in second user control. if the id's are different there is no problem - but in my case the usercontrols are being developed by different teams and I am integrating them in the way i mentioned - so they may have same ids.
View 2 Replies
Apr 16, 2010
I have a page with a few usercontrols. from a usercontrol I will redirect to a new page(response.redirect). Now On pressing the back button I want the data to persist for the usercontrols as well. I have tried it out by overriding DeterminePostBackMode, LoadPageStateFromPersistenceMedium, and SavePageStateToPersistenceMedium but all data except the ones within the usercontrol persist. i feel what i have tried is ok for the page data but for usercontrol data do i need to do something else.
P.S: I understand that i could be storing all user controls value in a session but I am looking for another way because its going to be a huge task taking each controls values in a session. I am not using any dynamically loaded user controls. May be if I know of a way of saving and restoring viewstate for user controls it would work but..
View 1 Replies
Jun 17, 2010
I want to know is there any other way to reset the sessions in page load?after delete the controls
i tried with Session.Abandon() -it kills all the session in page
this my code
[code]....
View 2 Replies
Feb 2, 2011
i am entering the value in a txtCountry and txtState if the other country and other state option is been selected. while i am entering the otherCountry and OtherState option at the dropdown lists Databound event.
so at the time of getting the data from database if the other option is selected then i am giving the variable value to the txtCountry and txtState likewise. but here i am not getting the exact output and getting error.
my code looks like below.
[Code]....
in above Code the ViewData function gets the data at edit time from the database
View 1 Replies
Oct 6, 2010
I wanted to know the best practice for caching data. Say I have some control example a dropdown list which is populated from my db. Now this dropdown is global and used across many pages. I was thinking of not going to database everytime to fetch data for this dropdown and put the result in Cache. And then populate this dropdown from cache. Is this a good practice or if there is another approach. Can I store my datareader in cache and then use it globally. Also could I do this in application start event?
View 4 Replies
Feb 21, 2011
I would like to find a solution to my problem. In these senario I've got two pages.
First page:
5 dropdowns in updatepanel and a gridview in updatepanel
Second page:
Displays info of the selected row
Problem:
So if a user makes a selections on all dropdownselection and selectes to view a row, wich in this case goes to page2 for more info.
But when the user returns to page1 all the selections and gridview has the "default" values so to speak, and not what the user has selected.
View 2 Replies
Dec 3, 2010
How to implement caching to a dropdown list
View 2 Replies
Aug 11, 2010
I am having a dropdownlist and fill it by providing dataset its working on page now what i want is when i am click on a button page is transfer to another page but from that page when i am back i want dropdown value selected.
View 4 Replies
Jul 23, 2010
I have a web form with a whole bunch of drop down lists (mainly) that works perfectly well and has been for some time. However, we've found a scenario that seems to corrupt the viewstate of this form in someway, or cause it to lose it's viewstate. The problem occurs when the user has this form displayed, then clicks on a link that opens up another window. A few more steps to open up a second and third window, followed by a write to the database. Then the user closes these windows down, leaving this original window open. At this point, the user selects something from one of the dropdowns. And the app crashes because the dropdowns have lost all of their values (and so a bit of code that is trying to work with one of the ddl's selectedvalues fails).
When the user selects this dropdown, the page_init event fires, followed by the page_load with postback = true. The dropdowns themselves are defined in the aspx page markup, but the values of them are generated and added in page_load (where postback = false). I've relocated the code to populate these controls to the page_init code and now the app doesn't fall over, because the values are re-populated. However, all of the selectedindexes are being reset, so the original values are lost and the screen redraws after this postback with all of the dropdowns reset.
View 1 Replies
Oct 12, 2010
how can DropDownList attributes be persisted accross page Postbacks?
Example:
DropdownList1.AutoPostBack = True
DropdownList1.items(0).Attributes.Add("Attribute1","somevalue")
On Postback the attribute is no longer available (ie. attributes.count=0).
I tried persisting using the code below, but was unsuccessful:
Before PostBack: ViewState.Add("DDL","DropdownList1")
On PostBack: DropdownList1 = ViewState("DDL")
This generated the error: DropDownlist is not marked as serializable.
I than tried:
Before PostBack: Session.Add("DDL","DropdownList1")
On PostBack: DropdownList1 = Session("DDL")
This did not err but attributes were still not available.
View 4 Replies
Nov 26, 2010
How we can create country state city dropdown in asp.net?
View 6 Replies
Mar 27, 2010
I have four dropdowns in the first page and then a button which saves the selected values from the dropdown to a session state .
In the second page I do have previous button which comes to the first page. My problem is that the dropdown values are not getting preserved.
Here is my code for the First page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyBusinessLayer;
using MyDataLAyer;
[Code]......
The problem is that I get the error object instance not set to an instance of an object
View 3 Replies
Mar 17, 2011
I've a ASP.Net page (Default.aspx) which will load UserControl (ucontrol.ascx) dynamically into an UpdatePanel. By using UpdatePanel, we believe we're able to prevent the entire page to be posted-back.
My problem is, within the UserControl, we have some form controls, such as inputs and buttons; after the UserControl is loaded, clicking on any button inside the UserControl will cause the UpdatePanel to be blanked. During the investigation, I found that, breakpoints within the Button1_Click() in the code-behind for the UserControl is never reached. Please reference to the code below, this references to [REFERENCE]1.
[code]....
View 2 Replies
Jul 17, 2010
This is page load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{ [code]...
But in my ascx.cs when IButton1_Click is trigered My name is null
private string _sname;
protected void Page_Load(object sender, EventArgs e)
{ [code]...
View 2 Replies
Jan 28, 2011
I have a page with an UpdatePanel with a UserControl in it. That UserControl contains a GridView with a nested UserControl that seems to disappear when the parent UserControl is rebound. I cannot for the life of me figure out why the child UserControl disappears. The code works beautifully on the first load, but any partial postback causes the "Pick" UserControl to disappear.
[Code]....
View 5 Replies