Web Forms :: DropDownList With ListItem To Resource - Files Breaks SelectedIndexChanged?
Jan 12, 2011
I am adjusting my DropDownList on my MASTERPAGE to point to resourcefiles - like this:
<asp:DropDownList runat="server" ID="Language1" AutoPostBack="true" OnSelectedIndexChanged="Language1_SelectedIndexChanged">
<asp:ListItem value="0" Text="<%$ Resources:SiteMapLocalizations, DropDownSelect1%>"></asp:ListItem>
<asp:ListItem Value="0" Text="<%$ Resources:SiteMapLocalizations, DropDownSelect2%>"></asp:ListItem>
<asp:ListItem Value="0" Text="<%$ Resources:SiteMapLocalizations, DropDownSelect3%>"></asp:ListItem>
</asp:DropDownList>
Problem now is that my SelectedIndexChanged has broken its funktionality in MasterPage.master.vb:
Protected Sub Language1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim cookie As New HttpCookie("SelLang")
cookie.Value = Language1.SelectedValue
Response.SetCookie(cookie)
Response.Redirect(Request.UrlReferrer.AbsoluteUri)
this is for the redirecting to the referrer page
End Sub
View 4 Replies
Similar Messages:
Apr 7, 2010
In our web application we need to keep various company's settings. For eg "DiamondProdRefIDCaption","Shippingpickup","ZipCodeCaption","DefaultCountry","AllowToEditInvoice", etcThese settings are different for various companies and are placed in web.config as key-value pair.Initially, we have tried do simplify this process by adding a company_settings table in the DB so as to allow us to add companies on the fly. However, this method makes it very difficult to add a new setting
<%$Resources:DiamondProdRefIDCaption%>
View 3 Replies
Jun 29, 2010
I have two radiobuttons in radiobuttonlist and based on selection, i am enabling and disabling the text box.
First time i used date radiobutton and i took date in corresponding textbox and i saved it into database and then when i came back on same page i saw the date radiobutton is checked has proper value then i clicked on another radiobutton and this time page is postback and clear my all the data which was in my other controls(I have 5-6 text boxed on my page). I dont know why?, It supposed to select my other radiobutton and enable the corresponding text box
[Code]....
if (!Page.IsPostBack)
{
if (gvCredentialTypes.SelectedIndex >= 0)
{
CredentialType credType = CredentialType.FindCredentialType(gvCredentialTypes.SelectedValue.ToString());
if (!String.IsNullOrEmpty(credType.CredentialTypeName)) //If exists, load data
{
String expDays = credType.ExpirationLength.ToString();
DateTime expDate = Convert.ToDateTime(credType.ExpirationDate);
// Assign the value to the controls
LoadExpirationDaysDateValue(expDays, expDate);
}
}
}
private void LoadExpirationDaysDateValue(String expDays, DateTime expDate)
{
// Determines whether value for Days or Date is present
Boolean IsDays = false;
// Check if days value is present
if (String.IsNullOrEmpty(expDays) || expDays.Equals("0"))
{
txtExpirationDays.Text = String.Empty;
}
else
{
txtExpirationDays.Text = expDays;
IsDays = true;
}
if (expDate.ToShortDateString().Equals ("1/1/0001"))
{
txtExpirationDate.Text = String.Empty;
}
else
{
txtExpirationDate.Text = expDate.ToShortDateString();
IsDays = false;
}
// Set the radio button value based on whether Date or Days value is present
if (IsDays)
{
// Get ref to the 1st radio item
ListItem liExpirationInDays = rbExpiration.Items.FindByValue("rbExpirationInDays");
if (liExpirationInDays != null)
{
liExpirationInDays.Selected = true;
rbExpiration.Items.FindByValue("rbExpirationDate").Selected = false;
txtExpirationDate.Text = string.Empty;
txtExpirationDays.Text = expDays;
// Enable or disable the controls based on the radio button selection
txtExpirationDays.Enabled = true;
RequiredFieldValidator1.Enabled = true;
RangeValidator1.Enabled = true;
txtExpirationDate.Enabled = false;
RegularExpressionValidator1.Enabled = false;
CalendarExtender2.Enabled = false;
//compDateValidator.Enabled = false;
RequiredFieldValidator2.Enabled = false;
}
}
else
{
// Get ref to the 2nd radio item
ListItem liExpirationDate = rbExpiration.Items.FindByValue("rbExpirationDate");
if (liExpirationDate != null)
{
liExpirationDate.Selected = true;
rbExpiration.Items.FindByValue("rbExpirationInDays").Selected = false;
txtExpirationDays.Text = string.Empty;
txtExpirationDate.Text = expDate.ToShortDateString();
// Enable or disable the controls based on the radio button selection
txtExpirationDate.Enabled = true;
RegularExpressionValidator1.Enabled = true;
RequiredFieldValidator2.Enabled = true;
CalendarExtender2.Enabled = true;
//compDateValidator.Enabled = true;
txtExpirationDays.Enabled = false;
RequiredFieldValidator1.Enabled = false;
RangeValidator1.Enabled = false;
}
}
}
private void EnableCorrespondingTextbox()
{
switch (rbExpiration.SelectedItem.Value)
{
case "rbExpirationInDays":
txtExpirationDays.Enabled = true;
RequiredFieldValidator1.Enabled = true;
RangeValidator1.Enabled = true;
txtExpirationDate.Text = String.Empty;
txtExpirationDate.Enabled = false;
RegularExpressionValidator1.Enabled = false;
CalendarExtender2.Enabled = false;
RequiredFieldValidator2.Enabled = false;
//compDateValidator.Enabled = false;
break;
case "rbExpirationDate":
txtExpirationDate.Enabled = true;
RegularExpressionValidator1.Enabled = true;
RequiredFieldValidator2.Enabled = true;
CalendarExtender2.Enabled = true;
//compDateValidator.Enabled = true;
txtExpirationDays.Text = String.Empty;
txtExpirationDays.Enabled = false;
RequiredFieldValidator1.Enabled = false;
RangeValidator1.Enabled = false;
break;
}
}
protected void OnSelectedIndexChangedMethod(object sender, EventArgs e)
{
EnableCorrespondingTextbox();
}
View 4 Replies
Mar 30, 2011
Why I can't change my listitem value on my dropdownlist?
View 6 Replies
Jan 25, 2011
I have a question about adding a ListItem to a DropDownList that is being bound by a SqlDataSource.
My Intention is to be able to add an item with something like "0" as a value and "--- Choose Something---" as the item.
However, the control is filled using a SqlDataSource for the DataSource.
So, the question is:
Is it possible to insert the value "0" and item "--- Choose Something---" to the control even though the control has a datasource from the database?
View 2 Replies
Mar 4, 2010
I have the following Dropdown List
[code]....
My problem is that some of the users that used to be in the list have left the company so we want to mark them inactive. When they are inactive they should not show up in the DDL to be selected to be assigned to. But there are existing records that they are already assigned to. If they are no longer able to be assigned their is a column called IsActive in the db that is set to 0. The Datasource filters for only == 1 when filling the datasource.
When it tries to render the control where a selected value is not in the list the Browser throws an error. I can not seem to find an event where I can intercept and set a value that is legal.
The solution I would like would be to add the listItem to the Control in the code behind then call the bind("AssignedTo") in the code behind instead of in the aspx page. This way linq would still handing the update of the DB record for the update event.
View 7 Replies
Sep 25, 2010
I have a databound dropdownlist, bound to an object datasource. I want to have a default value of "None" inserted at the top of the list and I would like to do this declaritively if possible. After much googling I came up with the below code. However it does not display my default item. I was under the impression that setting the AppendDataBoundItems to True would solve this, however it hasn't.
<asp:DropDownList runat="server" ID="ddl" DataSourceID="ldsCompany" DataTextField="CompanyName" DataValueField="CompanyId" SelectedValue='<%# Bind("CompanyId") %>' AppendDataBoundItems="True">
<asp:ListItem Value="DefaultValue" Text="DefaultText"/>
</asp:DropDownList>
View 1 Replies
Jun 22, 2010
I have one dropdownlist control which populates values to other controls. Means upon selecting item in dropdownlist, related data is populated in other controls. I have also assigned dropdownlist's autopostback to TRUE. Everything is working good as far as dropdown has more than one item.
Whenever there is only one item, selectedindexchanged event is not fired (obviously.....) and eventually the data is not populated to other controls.
How could I get rid of this scenario? I mean which event should I use to avoid this?
At this time, I have just added the first item as something like "---Select Item---" , so when end-user has to select different item and thus the selecteditemindexchanged is fired. no biggie... but just wondering if proper solution is available....
View 3 Replies
Feb 1, 2011
I have a DropDownList.
I need populate it with item collected in a List<ListItem>.
In my script, collector has been populated properly.
But I cannot populate the DropDownList. I receive an error:
DataBinding: 'System.Web.UI.WebControls.ListItem' does not contain a property with the name 'UserName'."}
<asp:DropDownList ID="uxListUsers" runat="server" DataTextField="UserName"
DataValueField="UserId">
List<ListItem> myListUsersInRoles = new List<ListItem>();
foreach (aspnet_Users myUser in context.aspnet_Users)
{
// Use of navigation Property EntitySet
if (myUser.aspnet_Roles.Any(r => r.RoleName == "CMS-AUTHOR" || r.RoleName == "CMS-EDITOR"))
myListUsersInRoles.Add(new ListItem(myUser.UserName.ToString(), myUser.UserId.ToString()));
}
uxListUsers.DataSource = myListUsersInRoles; // MAYBE PROBLEM HERE????
uxListUsers.DataBind();
View 6 Replies
Mar 2, 2011
Getting an unexpected event firing dropdownlist's selectedIndex event. When I try to redirect from another page by a linkButton. I just changing dropdownlist selectedIndex.Its okay.But after that When I attempt to redirect to another page,DropDownList's selectedIndex event firing (before linkButton Onclick event).But I am not changing any thing in dropdownlist.Somehow its event firing.
also any page viewstates is default (not off).But loading webcontrols into masterpage Page_Load like this :
[Code]....
if this dropdownlist selectedIndexchanged event firing. Because of I am loading webcontrols each masterpage's PageLoadEvent.
What do you prefer this may the reason of this unexpected event firing ? if so. Do you have a better technic to load controls Just for one time and not each pageLoad.maaybe a caching technic I am missing or shoult I use substution.
I couldnt find the main reason why a dropdownlist selectedIndexchanged event firing without I changed anything on that dropdownlist.
what reasons may cause this problem ? if you say viewstate its turned on defaultly. any other reason you know why ?
View 2 Replies
Nov 30, 2010
I have several DropDownLists which get data from database, that is,
first DropDownList has static data, second DropDownList gets data according to selectedItem of first DropDownList, and so on..
There cases when second DropDownList has only one item, in that case I cant call SelectedIndexChanged.
How to manage it ?
View 1 Replies
Mar 12, 2010
Basically I have a dropdownlist (ddlSystem) and an AJAX update panel. Inside the update panel I have an asp:GridView (gvSystemSpecs) and an asp:Image (imgLoad).
For triggers on the update panel I have:
[Code]....
When the user changes ddlSystem it makes a service call to pull back a bunch of data and populate the gridview.
I want to be able to show a loading image (imgLoad) when ddlSystem is changed. Once the function to pull data and populate the gridview is complete I need to hide the loading image.
I think I'll need to use some JavaScript, but what ever I try doesn't work and I don't know if the update panel has anything to do with it...
View 2 Replies
Jan 11, 2011
I want to get dates from Database to a calendar > on a dropdownlist Selection.. This is what i was doing on page load
[Code]....
I tried using it in dropdownlist SelectedIndexChanged but something is not right! here is the rest of the code for dayrendar event and
[Code]....
What should i do ?
View 18 Replies
Jan 8, 2011
i am using dropdownlist selectedindexchanged event , it is working with good speed in ie 6 or ie 7. But working slow in ie8.
View 2 Replies
Jan 19, 2010
i have two dropdownlist in my webform both are filled dynamically in the page_load event
[Code]....
View 8 Replies
Nov 11, 2010
I have the following in a web user control:
asp:DropDownList
ID="ddlPrescriptionCodeGroup"
runat="server"
AppendDataBoundItems="True"
AutoPostBack="True"
DataSourceID="PrescriptionCodeGroupDataSource"
DataTextField="CodeGroupDescription"
DataValueField="PrescriptionCodeGroupID"
onselectedindexchanged="ddlPrescriptionCodeGroup_SelectedIndexChanged">
<asp:ListItem
Text="--Please Select--"
Value="-1"></asp:ListItem>
<
</asp:DropDownList>
<asp:SqlDataSource
ID="PrescriptionCodeGroupDataSource"
runat="server"
ConnectionString="<%$ ConnectionStrings:RadiotherapyConnectionString %>"
SelectCommand="SELECT [PrescriptionCodeGroupID], [CodeGroupDescription] FROM [PrescriptionCodeGroup] WHERE (([Archived]
= @Archived) AND ([OrganisationID] = @OrganisationID))">
<SelectParameters>
<asp:Parameter
DefaultValue="False"
Name="Archived"
Type="Boolean"
/>
<asp:SessionParameter
Name="OrganisationID"
SessionField="OrganisationID"
Type="Int32"
/>
</SelectParameters>
</asp:SqlDataSource>
<asp:DropDownList
ID="ddlPrescriptionCode"
AutoPostBack="True"
runat="server"
AppendDataBoundItems="True"
onselectedindexchanged="ddlPrescriptionCode_SelectedIndexChanged"
DataSourceID="PrescriptionCodeDataSource"
DataTextField="CodeDescription"
DataValueField="PrescriptionCodeID"
>
<asp:ListItem
Text="--Please Select--"
Value="-1"></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource
ID="PrescriptionCodeDataSource"
runat="server"
ConnectionString="<%$ ConnectionStrings:SystemConnectionString %>"
SelectCommand="SELECT [PrescriptionCodeID], [CodeDescription] FROM [PrescriptionCode] WHERE (([Archived] = @Archived)
AND ([PrescriptionCodeGroupID] = @PrescriptionCodeGroupID))">
<SelectParameters>
<asp:Parameter
DefaultValue="False"
Name="Archived"
Type="Boolean"
/>
<asp:ControlParameter
ControlID="ddlPrescriptionCodeGroup"
Name="PrescriptionCodeGroupID"
PropertyName="SelectedValue"
Type="Int32"
/>
</SelectParameters>
</asp:SqlDataSource>
When I select from the first dropdown I want to populate the second. However, this is not happening. The postback is happening, but the SelectedIndexChanged handler isn't being called (I have a breakpoint which isn't being hit). The user controls are created dynamically and put into a PlaceHolder which itself is within an AJAX Updatepanel, with ChildrenAsTriggers set to true.
View 12 Replies
Apr 28, 2010
I have in my MasterPage a DropDownList that appears in all my Pages. I want it to run a specific code when user select another item in the list, but the event SelectedIndexChanged in the MasterPage doesn't work. How can I do to get this event working?
View 1 Replies
Jul 10, 2010
on SelectedIndexChanged event handling of DropDownList in ItemTemplate of ListView. I put OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" in mark up, with code behind, but only to get Compiler Error Message: BC30456: 'DropDownList1_SelectedIndexChanged' is not a member of 'ASP.webform1_aspx'. How do I make it a member? When I do not put OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" in mark up, BC30456 does not pop up, but nothing happens when dropdownlist selected item is changed.
[Code]....
View 1 Replies
May 7, 2015
I have a gridview and dropdownlist, let say the content of dropdownlist is YEAR and the content of gridview is Name and Year. Now for everytime I change the Value of dropdownlist the content of gridview will change but it will not load the page
View 1 Replies
Jul 7, 2010
I wrote a small .NET applications that removes all line breaks in aspx/html/css code to make it harder to read for people trying to steal my design. And surprisingly I get weird characters that appear out of nowhere such as Â, » and others. They all stay at the same places, but I have no clue why they appear.
View 2 Replies
May 7, 2015
I have two tables :
1- Builder
2- Project
Structure of Builder Table :
IDÂ Â Â Â Â Â Â INTÂ Â Â Â Â Â PKÂ Â Autogenerated
Name   nvarchar(50)
Structure of Project Table :
IDÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â INTÂ Â Â Â PKÂ Â Â Â Autogenerated
BuilderIDÂ Â Â Â Â Â Â INTÂ Â Â Â
ProjectName    nvarchar(50)
Now i have a dropdown combo which is manually binded to Builder Table , what i want is that it would disable all those builders in the dropdown to be selected which are residing in Project Table.
View 1 Replies
Oct 27, 2010
In our asp.net web application we load the dropdown list boxes in the page load. We than set the SelectedValue of each dropdown list box to an object from session. We have event handlers for many of the SelectedIndexChanged events of the drop down lists boxes, but these do not get executed when we set the selected value programmatically.
Someone else mentioned this is by design, and only when a user manually changes the drop down list selected index, will the event get raised.
I would think this is a common scenario of wanting the selectedindexchanged event handled when setting the selectedvalue/selectedindex/listitem's selected property, of a DropDownList. What is the suggested way to handle this? Is there a significant drawback of creating a custom control inherited from DropDownList that has the functionality of raising this event when changing the SelectedIndex or SelectedValue?
View 1 Replies
Aug 12, 2010
I'm trying to display a confirm message box before firing selectedIndexChanged when user change selection in the dropDownList. I was wondering if anyone would an example of how to do this.
View 14 Replies
Oct 5, 2010
I have a dropdownlist in a repeater and it's firing the SelectedIndexChanged event but in teh event handler I can not get the dataitem associated with the row that the DDL is in. Here is the code:
View 2 Replies
May 12, 2010
<asp:DropDownList ID="cboItemsPerPage" runat="server" CssClass="standardComboBox" AutoPostBack="true" EnableViewState="true" OnSelectedIndexChanged="cboItemsPerPage_SelectedIndexChanged">
<asp:ListItem Value="1" Text="1" />
[URL]Initially if I make a selection it will automatically post back and firecboItemsPerPage_SelectedIndexChanged. If I then post back by clicking one of the other buttons on the page, cboItemsPerPage_SelectedIndexChanged will continue to fire, despite the fact that the value has not been changed.I want it to be postback only when selected index is changed, not in every postback
View 3 Replies