MVC :: Caching Items For DropDownList?
Jan 20, 2011
I have a dropdownlist that contains items from a database. The set of items are unlikely to ever change. At the moment, whenever a user tries to access the View with the dropdownlist, the code retrieves the data each time from the DB. I would like to change this so that the set of items are cached and load on the application start only.
Could somebody indicate the best mechanism for this scenario? I have read up on Enterprise library which is my current preference, though any alternatives (with reasons) would be welcome.
View 5 Replies
Similar Messages:
Sep 6, 2012
protected void DDLzone1_SelectedIndexChanged(object sender, EventArgs e)
{
BindDistrict();
}
[Code]......
here when i click on ALL item from ddlzone1 it just "ALL" item in ddldistrict
i want when i select "ALL" item from ddlzone1 in ddldistrict14 show all data from database
View 1 Replies
May 21, 2010
I'm experiencing what seems to be a caching issue with Google Chrome and Safari on my cart page. In the cart there are 2 dropdown lists. When you hit the checkout button after changing the values in the dropdown lists, it commits what's selected in the lists to the database.
It's a little bit hard to explain the unexpected behavior so I will try to write it out step by step with an illustration of my problem.
Lets say the first dropdown list has the values of:
VALUE1
VALUE2
VALUE3
And the second dropdown list has the values of:
DUMBO1
DUMBO2
DUMBO3
I add an item to my cart.
Screen Says: VALUE1, DUMBO1
Database Says: VALUE1, DUMBO1
I hit Checkout.
Database says: VALUE1, DUMBO1 (I can't see the dropdown lists after I hit checkout because i'm not at the cart page)
I hit the back button.
Screen Says: VALUE1, DUMBO1
Database Says: VALUE1, DUMBO1
I drop down the VALUE1 combo and select VALUE2, VALUE2 is selected momentarily and then the site posts back and VALUE1 is re-selected in the drop down list (from being reloaded from the DB)
MOMENTARILY Screen Says: VALUE2, DUMBO1
Database Says: VALUE1, DUMBO1
THEN AFTER POSTBACK FROM DROPDOWNLIST_SELECTIONCHANGED EVENT
Screen Says: VALUE1, DUMBO1
Database Says: VALUE1, DUMBO1
Hit Checkout.
Database Says VALUE1 ,DUMBO1 (I can't see the dropdown lists after I hit checkout because i'm not at the cart page)
Go back.
Screen Says: VALUE2, DUMBO1
Database Says: VALUE1, DUMBO1
So it appears that it's remembering my selection of VALUE2 even though it jumped back to VALUE1 before I checked out.
It seems to be a caching problem, however I've got some no-cache code to prevent caching of that page that works great in firefox and internet explorer but seems to be failing in Chrome and Safari. I'm basically returning in the headers for the cart page: no-cache, no-store, and must-revalidate to attempt to prevent caching, but based on this scenario it seems to be caching the page anyway and not reloading it when I hit the back button.
View 1 Replies
Jun 14, 2010
I have a page with a number of user controls, In one of my user controls I have a button event. I turn on output cache for the user control that has the button and vary by control using the ID property of a hidden field control in the user control. whenever I turn on the output cache my button event doesn't fire.
View 2 Replies
Apr 29, 2010
how i handle this problem..Its in hidden filed.
Server Error in '/DentalClaimPrjt' Application.
Cannot have multiple items selected in a DropDownList.
Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Cannot have multiple items selected in a DropDownList.
Source Error: [Code]....
Line 85: function openPopup2(did)
Line 86: {
Line 87: var hdnClm1 = document.getElementById('<%=hdnCliamid.ClientID%>').value;
Line 88: window.location="Form.aspx?DeleteRSPid=" + did + "&Editid="+ hdnClm1;
Line 89: }
Source File: d:DentalClaimPrjtForm.aspx Line: 87 Stack Trace: [Code]....
[HttpException (0x80004005): Cannot have multiple items selected in a DropDownList.]
System.Web.UI.WebControls.DropDownList.VerifyMultiSelect() +106
System.Web.UI.WebControls.ListControl.RenderContents(HtmlTextWriter writer) +124
View 2 Replies
Mar 22, 2010
I have a drop down list as follows:
[Code]....
[Code]....
View 1 Replies
Jan 5, 2011
I'm designing a web page with two dropdownlists, one for the Make of a car, the other for the Model, both bound to a database with separate SQLDataSources, and using a distinct statement. I add "All" at the top of both by setting appendDataBoundItems = true and adding items named all. Then when I fill the Make with a querystring all the model items get added twice (but only the databound items).Here's my code:
<asp:DropDownList ID="DropDownMake" runat="server"
DataSourceID="SqlMakes" DataTextField="Make" DataValueField="Make"
AppendDataBoundItems="True" EnableViewState="False" AutoPostBack="True">
<asp:ListItem Selected="True" Value="All">All</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownModel" runat="server"
AppendDataBoundItems="True" AutoPostBack="True" DataSourceID="SqlModels"
DataTextField="Model" DataValueField="Model" EnableViewState="False">
<asp:ListItem>All</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlMakes" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT DISTINCT [Make] FROM [Parts]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlModels" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT DISTINCT [Model] FROM [Parts] WHERE ([Make] = @Make)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownMake" Name="Make"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
'And in the VB file:
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
DropDownMake.SelectedValue = Request.QueryString("Make")
DropDownModel.SelectedValue = Request.QueryString("Model")
End Sub
If I remove the line "DropDownMake.SelectedValue = Request.QueryString("Make")" it doesnt produce duplicates anymore. What is going on?? I swear I've spent more time developing entire iphone app.
View 2 Replies
Apr 19, 2010
How can I copy items hardcoded from one dropdown box to another keeping the keys and values?
drpTypes.Items.Add(new ListItem("Tipos de Acções", "1"));
drpTypes.Items.Add(new ListItem("Tipos de Combustível", "2"));
drpTypes.Items.Add(new ListItem("Tipos de Condutor", "3"));
drpTypesCreateEdit.Items.AddRange(drpTypes.Items);
View 2 Replies
May 15, 2010
how to implement caching in wcf service using System.Web.Caching
View 2 Replies
Nov 26, 2010
I have a dropdownlist in a formview that looks like this:
<asp:DropDownList ID="DropDownList5" runat="server" AppendDataBoundItems="True"
DataSourceID="SqlDataSource6" DataTextField="StaffName"
DataValueField="StaffName" SelectedValue='<%# Bind("LetterName") %>'
Width="155px">
<asp:ListItem Value=""> </asp:ListItem>
</asp:DropDownList>
I am trying to add the value from a textbox which is also in the formview into the dropdownlist as a list item. I currently have this code for it:
Protected Sub Formview1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.PreRender
Dim dropdown As DropDownList
Dim listvalue As TextBox
dropdown = FormView1.FindControl("dropdownlist5")
listvalue = FormView1.FindControl("textbox1")
dropdown.Items.Add(New ListItem(listvalue.Text, listvalue.Text))
End Sub
This code works and adds the new item to the dropdownlist if I have no SelectedValue set for my dropdownlist. However when I set the selectedValue I get the error message:
"'DropDownList5' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value"
This is the bit I dont understand because the value does now exist in the list of items as it was added in from the textbox value. Does it try to do the selectedValue before adding my list item? If so how can I add the list item first, or do I need to set the selectedValue in the code after adding the list item?
View 3 Replies
Jan 14, 2010
i have a database table with lot of records > 17000what is the most efficient way to let user to choose between one of the records- 1 dropdownlist with all the 17000 record ?- 1 textbox with autocomplete and a webservice that return the list of the records ?
View 3 Replies
Jan 10, 2011
I have a dropdownlist with items. dropdownlist got it from a List<string> object.
Now i want to set a hyphen for all the items. so i looks like this:
- a
- b
- c
Does anyone know a way to do this?
View 5 Replies
Apr 14, 2010
On the home page as I on work, I have a dropdown list which act as a menu. But in Internet Explorer can not figure out how to display all text in my dropdown list How it looks in Internet Explorer
How it looks in firefox, chrome and opera Do you know how to do so that Internet Explorer also displays all the text in my dropdown list like in firefox and the other
View 2 Replies
Sep 17, 2010
I have a cascading dropdown list on my page. The first dropdown contains a list of events. The second dropdown contains a list of attendees. When an event is selected, an AJAX call is made to get the list of attendees for that event, and populate the second dropdown.
My problem is that for the attendees dropdown, I want the user to be redirected to a URL on the SelectedIndexChanged event, with the selected value in the query string. But on the SelectedIndexChanged event, all the items in the second dropdown are reset. Here's my code:
<script type="text/javascript" language="javascript">
$(document).ready(function()
{
$('#<%= ddlEvents.ClientID %>').change(function()
{
$.ajax({
[Code]....
When the SelectedIndexChanged event is hit, ddlAttendees is empty.
Does anyone know how I can keep the items in ddlAttendees?
View 2 Replies
Mar 23, 2011
Using MVC2, I want to know how you add the options of a dropdownlist from a database. I have several lookup lists so I will need to do this many times. I'm stuck on part 5 of the MusicStore (which is using MVC3) at this part
[Code]....
Alternatively if someone could recommend an MVC2 tutorial which covers drop lists.
View 9 Replies
Jul 11, 2010
I'm using DropDownList within my WebApplication. I need to keep additional piece of information with each Item on list. How can I achieve this?
View 3 Replies
May 15, 2010
I want give some space between the items of the dropdownlist. is it possible?
ddl:
item1
item2
item3
View 3 Replies
Aug 25, 2010
I have dropdownlists in Gridview. I need to dinamicly change content of dropdown on client with javascript. Ok, I know to do that. But the problem is when I send data to server changes in dropdownlist does not see. On server I have old items. How can I change items in dropdown on client with javascript and than see that items on sever when postback data?
View 5 Replies
May 7, 2015
how to count the common data from two dropdownlist control.ex..
1st dropdownlist have 1 2 3 4
2 nd dropdownlist have 3 4 5
so the count of common value is 2 (3 4)..how to calculate this.
View 1 Replies
Jan 24, 2016
Category and Sub Category in single Drop Down List DDL example with showing subcategory inside Main Category...
View 1 Replies
Dec 24, 2010
On adding items in it ,shows an error: "Dropdownlist does not allow multiple selection."But when i tries to print the selected item it shows null exception.
View 6 Replies
Aug 2, 2010
I'm using a text book to teach myself ASP.NET 3.5. I'm using Visual Web Developer 2008 express to create my pages. At this point in my text, the author has me drag a DropDownList control to the Web page and then tells me to go to the Properies window and look at the Items property. I don't see an Items property. I've doublechecked that I'm on my DropDownList control, but I see no Items property. Is this a bug in VWD, an error in the book, or just plain old User error?
I'd be willing to hard-code the property in the source window, but I don't know the syntax. I tried
items="Vanilla, Chocolate" but nothing appears in the list when I view the screen.
View 5 Replies
Nov 18, 2010
I have a dropdownlist which get item from database (say this field has 10 records for this dropdown list.
I want the users are not restricted to these 10 items. What is the quickest way to do so the user can type in new values and insert into database ?
View 4 Replies
Aug 12, 2010
I would like to highlight (bold) and disable certain items in the dropdownlist for selection.
My dropdownlist is fed from a SQL table of countries e.g.
Europe
-UK
-FR
-DE
-AU
I need to heading "Europe" to be not selectable? the database has a column (selectable = 0) for those heading and I need to make them not selectable on the client side.
View 9 Replies
Oct 11, 2010
I see that dropdownlist has an "items" property to get the list of displayed items for a dropdown, but it doesn't seem to have an equivalent property for getting the "values" associated with the items. For example, I may have a dropdown that displays "High", "Medium" and "Low", but returns values of "H", "M", "L". How can I easily get that list of HML?
View 5 Replies