Web Forms :: Why Dropdown List Getting Reset After The Page Refreshes
Apr 9, 2010
I have a created a form using a user control. One of the dropdownlists in the form is populated after the user makes a specific selection from another dropdownlist...i.e. a dependent dropdown list. This is triggered using the SelectedIndexChanged event handler on the controllling dropdownlist.
The dependent dropdownlist gets populated correctly, but when I choose one of the options and go to submit the form, the dependent dropdown list is reset and doesn't maintain the selection that was made.
The controlling dropdown list ID is "level". The dependent dropdown list ID is "EnrollmentSize".
The "EnrollmentSize" DDL only losses the option that was selected. The DDL is sitll populated with all the correct values. It only losses the option that was selected and goes back to the first option...i.e. "Select..."
The viewstate on the page is enabled and all the other form values are maintained. It is only happening with the EnrollmentSize ddl.
I've set breakpoints and tried debugging and I do see that the EnrollmentSize.SelectedValue is an empty string, but I don't see why or where that is happening in the button click event
I thought it had something to do with EnableViewState,but that is set to true and has no bearing. Everytime I try to submit the form, the "EnrollmentSize" DDL is reset and doesn't maintain the option that is selected.
[Code]....
[Code]....
View 4 Replies
Similar Messages:
Jan 3, 2011
i want to see the sales in the grid view based on the month selected from drop down list. Ex: when I select June 2010 from the ddl box, the sales for that month are correctly displayed in the grid view. I go to page 4 to look at some sales there and then switch the month to August 2010 to see sales for that month instead. Here is the problem. When I switch the month, it show August 2010 sales, but stays in page 4 instead of going back/resetting back to page 1 of August 2010 sales.
How do I reset the grid view page back to the first page of August 2010 sales?
I am fairly new to ASP. If I have missed an imp. detail in this post, let me know and I will get that info. out there.
View 4 Replies
Sep 8, 2010
Does anyone know how to do this so when I select something the 1st dropdown and the 2nd one becomes visible and populates list from a Select statement. I really need help on how to do in an aspx and not on the code behind page.
View 12 Replies
Apr 12, 2010
I'm having troubles remembering how to grab the list view's state, or page, so that when you leave the list, you can return to the list view page you left on. I have a data pager, and I have hyplerlinks for items in the list view that take you to a file upload or file delete page, and then returns to the list view. It returns to the list view's initial state (first page).
View 1 Replies
Oct 10, 2010
I am stuck at this point "Displaying a dropdown list of Categories with a --None -- Option. I want the gridview control to display 2 dropdown list one in read-only mode and the other in edit mode. When a record is in read-only mode, the dropdownlist's enabled property will be set to false."When it's on a read-only mode, it doesn't display the selected Category. it shows but the "No Category". When i click on edit to edit or change category, it doesn't display the selected category.
The example is given below( I am reading the book Sams Teach yourself ASP.NET 2.0 by Scott Mitchell. page 628)
<asp:Label ID="UserIdValue" runat="server" Visible="False"></asp:Label>
<asp:SqlDataSource ID="picturesDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [Pictures] WHERE ([UserId] = @UserId) ORDER BY [UploadedOn] DESC"
DeleteCommand="DELETE FROM [Pictures] WHERE [PictureID] = @PictureID"
InsertCommand="INSERT INTO [Pictures] ([UserId], [CategoryID], [Title], [Description], [UploadedOn]) VALUES (@UserId, @CategoryID, @Title, @Description, @UploadedOn)"
UpdateCommand="UPDATE [Pictures] SET [UserId] = @UserId, [CategoryID] = @CategoryID, [Title] = @Title, [Description] = @Description, [UploadedOn] = @UploadedOn WHERE [PictureID] = @PictureID">
<DeleteParameters>
<asp:Parameter Name="PictureID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="UserId" />
<asp:Parameter Name="CategoryID" Type="Int32" />
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="UploadedOn" Type="DateTime" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="UserIdValue" Name="UserId" PropertyName="Text"/>
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="UserId"/>
<asp:Parameter Name="CategoryID" Type="Int32" />
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="UploadedOn" Type="DateTime" />
<asp:Parameter Name="PictureID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<asp:SqlDataSource ID="categoriesDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [CategoryID], [Name] FROM [Categories] WHERE ([UserId] = @UserId)">
<SelectParameters>
<asp:ControlParameter ControlID="UserIdValue" Name="UserId" PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:SqlDataSource ID="maxPictureIDDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT MAX(PictureID)
FROM Pictures
WHERE UserId = @UserId">
<SelectParameters>
<asp:ControlParameter ControlID="UserIdValue" Name="UserId"
PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:Label ID="cannotUploadImageMessage" runat="server"
Text="The photo could not be added to your album either because you did not specify a file to upload or the file specified was not a JPEG image with the file extension .JPG"></asp:Label>
<br />
<asp:DetailsView ID="dvPictureInsert" runat="server"
DataSourceID="PicturesDataSource" Height="50px" Width="125px"
AutoGenerateRows="False" CellPadding="4" DataKeyNames="PictureID"
DefaultMode="Insert" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
<EditRowStyle BackColor="#2461BF" />
<FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
<Fields>
<asp:TemplateField HeaderText="Picture">
<InsertItemTemplate>
<asp:FileUpload ID="imageUpload" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="imageUpload" Display="Dynamic"
ErrorMessage="There was no file selected" ValidationGroup="PictureAdd"></asp:RequiredFieldValidator>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Category" SortExpression="CategoryID">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CategoryID") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="pictureCategory" DataSourceID="categoriesDataSource"
runat="server" DataTextField="Name" DataValueField="CategoryID"
SelectedValue='<%# Bind("CategoryID") %>'
Visible='<%# Bind("CategoryID") %>' AppendDataBoundItems="True">
<asp:ListItem Selected="True" Value="">-- Select Category --</asp:ListItem>
</asp:DropDownList>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Title" SortExpression="Title">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" Display="Dynamic"
ErrorMessage="you must provide a name for the title"
ValidationGroup="PictureAdd"></asp:RequiredFieldValidator>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description" SortExpression="Description">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description") %>'
View 2 Replies
Jun 3, 2010
I have two usercontrols.In one I am either typing a program name or selecting from a existing list and putting it in session. Then in the other usercontrol I am checking whether the session values exists or not and then setting the selected value of another dropdown according to the program name selected in the first one. My code for setting the value in the second one is as
protected void Page_Load(object sender, EventArgs e)
{
FillProgramList(select);
if (Session["ProgramName"] != null)
{
//FillProgramList(select);
programToExecute = Convert.ToString(Session["ProgramName"]);
select.SelectedValue = select.Items.FindByText(programToExecute).Value;
}
// other code
}
FillProgramList(select) is the function filling the second DD. Now this code works perfectly in my local system but does not work on the live server where it is deployed. I feel that an extra postback is happening there which is resetting the dropdown value in the second dropdown.If so what do I need to do for preventing that. I could be wrong.In that case I would like to know your opinion and how to solve it. Since I cannot debug on the live server I do not know as to what exactly is happening. Is there a way to find out exactly the problem without debugging on the live server.
View 10 Replies
Aug 29, 2010
I have applied nested master page to some page. Now i want to bind drop downlist from value selected in dropdown list in master page of master applied to that page.
the hierarchy of pages is
mypage.aspx -> main.aspx -> inner.master
I want bind dropdown list in mypage.aspx from from value selected in dropdown list in inner.master
View 2 Replies
Jan 18, 2010
I have only a textbox in a page. If I type something inside the textbox and click carriage return key (Enter), the page refreshes and the textbox becomes blank again.
What is actually happening here? Why the page refreshes? Is it the default property of asp.net?
View 11 Replies
May 1, 2010
i have n image button with an event:
[Code]....
when i click the button the page refreshs.. is it possible to make the event heppen without refreshign the page?
View 16 Replies
Jun 29, 2010
I have a dropdown list that is populated by certain information. However, though, I would like the dropdown to be empty whenever the page loads.
View 4 Replies
Apr 3, 2010
I have a page with 14 dropdown lists. In the first page load (ie. not isPostback) I set the selectedIndex of the dropdownlists individually but I find that they are all set to the value I use for the last dropdownlist set. Here is the code
comboFirstJudge1.SelectedIndex = 0
comboFirstJudge2.SelectedIndex = 0
<so on for all the dropdown lists until the last one>
comboFirstJudge14.SelectedIndex = 4
The result is that all dropdown lists have SelectedIndex = 4. If I run the same code on a postback it works just fine (the first lists have SelectedIndex = 0 and the last one = 4).
View 6 Replies
Dec 30, 2010
I would like to ask a question about hiding a drop down in my gridview. I have a gridview and I have a drop down list to control the page size of that gridview. when there is data in that gridview, it is fine for user to see the drop down list. But when there are records in the gridview, I do not want the user to see this drop down list. How can I hide it when there is no data?
View 2 Replies
Nov 3, 2010
I have 2 drop down lists.I have a very simple dropdown list #1 that diplays a title and holds an id value which is a GUID.I know it is getting this value and sending this value as I tested sending it to a label.I have the dropdown list #1 to autopostback to dropdown list #2 that "Is supposed to get" another title and value based on the GUID value of the first dropdown list. for some reason it wont return anything. I have done 100's of these but never based off a guid value.I assume the value needs to be converted to guid before selecting it in the second dropdown list.How can I do this? or is there something I am missing?
View 9 Replies
Mar 9, 2011
I have a dropdown control that has a list of names in it called PlayerNameDropDownList_Insert and a textBox called PlayerName.
When I select a name from the dropdown it populates the textbox correctly.However, when the page opens the first name is selected in the dropdown but nothing in the textbox. How can I get the textbox to populate with the value of the dropdown at pageload?
[Code]....
View 4 Replies
Mar 15, 2010
I have a drop down list embedded in a menu panel in my master page. This ddl fetches it's list items from my SQL Server. They are:
1. Select a type --appended during page load
2. Green type -- fetched from SQL server via a datasource
3. Red type -- fetched from SQL server via a datasource
4. User Manual -- appended during page load
For the sake of simplicity my website has 4 pages. When the 'Select a type' list item is selected - the user should be taken to a general 'Introduction' page. When the 'Green type' - the user should be taken to a 'Green' page - and etc.
View 1 Replies
Aug 27, 2010
I am having 2 web formsand will have a drop down list on those web forms. If i select a value from drop down and click on ok i will get tranfer to next page. In that page i will have a drop down with the same values in the previous form . What i need is i would like to disable the selected value in the previos form and would like to display the remaining normal.
View 3 Replies
Sep 10, 2010
I am struggling to login into my web portal on my new sony vaio laptop. I think that I need to do some settings, or download some plugin. Infact I don't know what to do, as I have spent many hours trying to login, but no success. Below is my office website:[URL]When I enter my credentials and click login, the web page gets refreshed, i.e username and password get erased, rather than taking me into my web-portal. The laptop is having windows 7 home premium, with ie8. I have also tried installing firefox, chrome, opera and safari, but same problem.
as sony has refused to take the laptop back and they are saying that there is problem with website. Similarly, website staff are saying that there is a problem with the laptop and not with the website.
View 3 Replies
Feb 10, 2010
Im implementing a simple form with ajax to warn the user if email has been used or not for registration, and it looks to be working fine with IE but mozilla does a full page postback and refreshes the whole page.
I already tried changing to updatemode to conditional, all the triggers are set as async, etc but mozilla keeps doing the same, Im sure it is a known problem I may not be the first one facing this problem so i guess there is a simple workaround for this.
View 2 Replies
Jun 12, 2010
I Have the gridview control with 2 dropdown list and 2 text boxes,When the textbox chnaged event happen 1 row will create and the dropdown back to initial values( its not retaining the selected values),I am binding the control after text changed method,Is there any properties needs to be set or any other way we can retain the values in postbacks?
View 4 Replies
Aug 17, 2010
I want to add a button in that page so that by clicking on this all the field will be reset.
is it possible?
View 4 Replies
Aug 18, 2010
I want to reset all the value when I am changing the tab.
In my case I have two tab. I want when I change the tab then the all previous tab value should be cleared. For refference I have tried with activetabchnged in .cs page but when I am changing the tab its not encountered.
In every page I have four cascaded dropdown.
View 1 Replies
Mar 6, 2010
I searched the forum for several days now , but can't find an answer to my problem.
I have 4 Ajax Cascading DropDown named,
ddlCatalogueName > ddlMainGroup > ddlSubGroup > ddlPageNumbers ,
I am passing the values obtained from ddlSubGroup and ddlPageNumbers to a datasource as parameter (Actually to a pageddata ) , on which i create a DataList.
The page is working fine actually but the problem is like the following,</p>
Considering that all dropdown are selected as following :
When i change ddlSubGroup to another one , ddlPageNumbers is populated depending on the number of items divided by 20 ( The datalist is paged by 20 items per time)
then i change the ddlSubGroup(RUBBER PARTS in this example for example to BodyParts , so the dropdown values becomes like :
[code]....
At this point Body PARTS also has page numbers like 1,2,3,4 etc but, it still remains as 2 , however i need the page number to reset back to 1.
Is there any way to do this , and where should i place the code exactly ( which event ) ?
View 2 Replies
Jun 3, 2010
I'm trying to set the selected value of a ddl during page load ie. before databind.
This causes "selected value does not exist" errors. So I force a databind, and add a new element if it does not exist in the data source.
However it looks like when the databind is performed later in the page lifecycle that my added element(s) are removed/overwritten.
Am I setting the values in the wrong part of the life cycle?
View 4 Replies
Dec 2, 2010
I've two SqlDataSources and two Repeaters, each repeater contains one hyperlink (i also tried using web server button and anchors). The hyperlinks fetch from the database some values and in the NavigationUrl property I use a string.Format method to create a parameterized url, to pass for the browser, then second repeater is populated according to the value passed in the url which is originally passed by the first repeater's hyperlink. this is my sample code : [URL]
<asp:ScriptManager id="Scrptmanagr" runat="server"></asp:ScriptManager>
<asp:UpdatePanel id="updtpanl" runat="server">
<ContentTemplate>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
SelectCommand="SELECT [arrange_by_id], [arrange_by] FROM [arrange_by]">
</asp:SqlDataSource>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:HyperLink ID="HyperLink3" NavigateUrl='<%# string.Format("{0}?SortingType={1}",Request.AppRelativeCurrentExecutionFilePath, Eval("arrange_by_id"))%>' runat="server"><%# Eval("arrange_by") %></asp:HyperLink>
</ItemTemplate>
<SeparatorTemplate>
|
</SeparatorTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
SelectCommand="SELECT [alphabet_id],[arrange_by_id], [value] FROM [alphabet] WHERE ([arrange_by_id] = @arrange_by_id)">
<SelectParameters>
<asp:QueryStringParameter Name="arrange_by_id" QueryStringField="SortingType" Type="Int32" DefaultValue="1" />
</SelectParameters>
</asp:SqlDataSource>
<br /><br />
<asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource2">
<ItemTemplate>
<asp:HyperLink ID="hyper1" runat="server" NavigateUrl='<%#string.Format("{0}?SortingType={1}&SortBy={2}",Request.AppRelativeCurrentExecutionFilePath, Eval("arrange_by_id"),Eval("value"))%>'><%# Eval("value")%></asp:HyperLink>
</ItemTemplate>
<SeparatorTemplate>
|
</SeparatorTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
Now! everytime I click any of the hyperlinks it causes a full post back and refreshes the page!
View 2 Replies
Feb 17, 2010
Clicking the label of a drop down list, re-sets the selected value to the first item in the list. This has a history of causing data entry problems when users accidently click on the label.
In the below example ddlContactType has a selected value as 'PRIMARY' and whenever i click on the lblContactType Text, the dropdown box Selected value is changing to "Select One" Text.
How to prevent this one. It should be on PRIMARY Only.
<p>
<tr> <td ><asp:Label ID="lblContactType" Font-Bold="true" Text="Contract Type: *" ForeColor= "red" runat="server" AssociatedControlID="ddlContactType"></asp:Label> </td> <td > <asp:DropDownList runat="server" ID="ddlContactType" DataSourceID="SqlDataSource2" AppendDataBoundItems="true"
DataTextField="TYPE" DataValueField="ID" SelectedValue='<%# Bind("CONTACT_TYPE_ID") %>'>
<asp:ListItem Text="Select One" Value="0" Selected="True"></asp:ListItem>.......
View 4 Replies