AJAX :: Set The Selected Value Of Cascading Dropdownlist By Reading From A Textbox
Mar 21, 2011
I'd like to set the selected value of cascading dropdownlist by reading from a Textbox.Text value when the dropdownlist has been populated, is this possible?
I'm wanting to maintain the dropdownlist values that were selected when i use postbackurl with a button. They cascading dropdowns are on a masterpage in an accordion pane. I select the 3 vales in the ddl and then presss a button which redirects to the new content page.
I've been able to get the values using previousPage.master.fincontrol... but am then setting the selectedValue in the page_init of the conent page, but they aren't set when the page loads... does anyone know where to put the code to set the values?
I have a cascading dropdown which is dynamically created and does a postback based on a certain condition. How do i set the selected value after the postback
I am binding the dropdownlist by using ajax cascading drop down now i need to preselect the dropdown value in code behind page in page load (for update operation) is it possible
Bit of a strange request but is it possible to set the selected value of a cascading dropdown in code? I have 2 dropdowns, the second is populated using the value of the first. Heres my markup:
I have a RadioButtonList and two cascading dropdown linked to corrspoding dropdown control. Based on radiobutton's selection, the cascading will be prepopulated with some values and one value is selected in both dropdown.
I want to disable the cascading dropdown/dropdown after values are filled and selected on selection of radiobutton selected in RadioButtonList.
I tried to disable it, but in that case dropdown is getting empty.
I have a web form where I have three dropdowns for Country State And City and there corresponding ajaxToolkit:CascadingDropDowns.
The dropdowns are working perfectly fine with the web service methods. i.e country loading initially and then State as per selected Country and City as per the selected City.
The problem occurs when I try to set selected values in these dropdowns as per the Values previously saved.
The Country loads properly and the selected value is set according.
The State is filled as per the selected country but its selected value is not set.
The City is not loaded at all (as the state doesn't have a selected value)
I have 3 dropdowns in my VB.Net 3.5 web app. After a user selects a value from the first (let's call it Countries) the second (called States) should populate correspondingly. Dropdown three (cities) should also cascade down after a State is selected. The Countries and States dropdowns have SQL DataSources. The Cities dropdown has to call 2 procs (based on the selected State value) so it does not have a SQLDataSource. My question is, the code below works for Countries and States, however, I cannot ge the Cities to populate...
<asp:DropDownList ID="drpCountries" runat="server" DataTextField="CountryName" DataValueField="CountryId" DataSourceID="sdsCountries" AutoPostBack="true"> </asp:DropDownList> <asp:SqlDataSource ID="sdsCountries" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" SelectCommand="SELECT * FROM [Countries] ORDER BY [CountryName] ASC"></asp:SqlDataSource> <asp:UpdatePanel ID="updStates" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:DropDownList ID="drpStates" runat="server" DataTextField="StateName" DataValueField="StateId" AutoPostBack="true" DataSourceID="sdsStates"> </asp:DropDownList> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="drpCountries" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel> <asp:SqlDataSource ID="sdsStates" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" SelectCommand="SELECT * FROM [states] WHERE StateId = @StateID ORDER BY [StateName] ASC"> <SelectParameters> <asp:ControlParameter ControlID="drpCountries" Name="StateID" PropertyName="SelectedValue" DefaultValue="" /> </SelectParameters> </asp:SqlDataSource>
THIS DOES NOT WORK:
<asp:UpdatePanel ID="updCities" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:DropDownList ID="drpCities" runat="server" DataTextField="CityName" DataValueField="CityId" AutoPostBack="true"> </asp:DropDownList> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="drpStates" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel> Protected Sub drpStates_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles drpStates.DataBinding ' Call some procs and get a DataSet drpCities.DataSource = ds drpCities.DataBind() End Sub
I am referring to following line from this link [URL] ....
data 'continentId ' 'ddlContinents.ClientID'.val ''
In your code. i tried using this code and facing a tiny problem. In above mentioned code 'ddlContinents.ClientID'.val stores integer value in contentId for obvious reasons but the requirement of my code is different. i want to pass text which is selected instead of id no.for example if mumbai is listed as second option and i select mumbai it should store mumbai in contentId instead of 2 i.e. integer value.
I am trying to get two cascading dropdownlist to work but cannot get either to populate. How do I de-bug this? I'm not getting any errors, just blank dropdowns.
I've been trying to fill in webservice from SQL Server. But in-case this was the problem. I found an example on this site to fill with test values, but this still does not work. Since I cannot even get first to populate, to simplify I'm just giving code for first dropdown and its function(s)
I am trying to select some data with dropdown lists which are related.
I select one of selection in dropdownlist1. After that, when my page reloads, dropdownlist2 is filled with table name which i am trying to get data from. (TBLYETKILI)
I think this needs to be a sticky since this is not solved anywhere that I have been looking... I have been googling this for a while now and came across the answer by shear luck and a simple typo when I was writing the code...
Problem: I have 2 dropdown lists...
ddllist1 and ddlist2... Both are code-behind populated via a sql DB.
they are cascading lists via the ajax control.
I am trying to dynamically populate them with values from a DB for edit reasons.
When I try to get them populated I kept getting the error...
"dropdownlist has a SelectedValue which is invalid because it does not exist in the list of items"
Solution:
1) get the values from the DB or from where ever...
2) create a sql select to get the values from the ddl db
3) set the ID of the first DDL control to cddcontrol1.SelectedValue = id (this is a number)
4) set the value of the DDL to the string value ddlist2.SelectedValue = value (this is a string)
I am dealing with a problem that i have to make decision based on the number of items in a cascading dropdownlist. unfortunately this ajax toolkit control does not expose a Items collection.how do i count the number of items in this control ?
Now i'm working on the cascading dropdownlist for to bind a country and city, city is based on country dropdownlist. its working well , if city comes more than 8000 records in city dropdownlist , takes more to bind city.
I really have no idea on this problem on the cascading dropdownlist. I have a cascading dropdownlist that bind with calling the web services.
I wan to do a autopostback to get the value of the Album GUId so that i can query out all the photo list of that album. it is working well if my page without the AlbumGUId query string.
my problem is:
when i redirect from other page and passing the Album GUId querystring to this page, it will display all my photo for this album guid. but when i change the album to Select which should be able to display all the Photos, it cannot display out. It only will work is when i choose another album and then go back to Select then it only can work..
at last project i need to deploy cascading dropdownlist without using web serive or cascadingDropDownList Extender
i try to do this using updatepanel :D this work , but at many times that apear my computer and my internet Explorer as busy and hang and i can not do any thing untill populate the second dropdownlist :(
is there any way to avoid that and to view a wait message until populate the second dropdownlist , i mean is there a sample code for doing that
I have two dropdownlist in cascading working, in my file file.aspx, all work good.the selected values from cascading dropdownlist bind my repeater. when select item inside repeater redirect me to second.aspx. when comeback to first.aspx i lose all selected values in cascading dropddowlist and also values in repeater.
i can populate cascading dropdownlist by using webservice now. but may i know how do i trigger function while selectedindex changed? (without using auto postback...)
district region city Id can 1 Canada 1 Lon 1 London 2 Ita 2 Canada 3
Now when I select city from DDlcity after that select region from DDlregion according to my selected item from DDlcity and DDlregion it bind DDlDistrict... before I used OnselectedIndexChange below is SP...
ALTER procedure [dbo].[SelectِDistrict] @Region NVARCHAR(30), @city NVARCHAR(40)
[Code] ....
It worked correctly but now I use cascadingdropdown list
[WebMethod] public CascadingDropDownNameValue[] GetDistrict(string knownCategoryValues) { string region = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)["Region"]; string query = string.Format("SELECT District FROM District WHERE Region = N'{0}'", region);
[Code] ....
problem is that when I select city=canada then region=1 I want it bind in DDldistrict =can but here it show in DDLdistrict can and Lon
here it just select district that region=1 it doesn't attention to city selected Item I want it do like SP that I used...
I wan to do a required field validation for the cascading dropdownlist . When my page first load out the validator is fired first in the google chrome, the callout extender message is prompt out first in the Google Chrome. I have tested the code in IE and safari, this two browsers never prompt out the validator callout first when the page is loaded.
i wonder why the google chrome will prompt out the validator when i validate the cascading dropdownlist. I have did some research on it, but failed to get any solution.
Have spent hours trying to create a Dynamic Data Field Template holding a DropDownList which is extended by the AJAX Cascading DropDown extension.Final form holds multiple cascading dropdown boxes. User selects Country (Land) then Postcodes, Counties (Provincie) are populated. Once postcode is selected then towns (Plaats) are populated. The problem I am now facing is that the viewstate for the dropdown lists is not being saved/restored after an insert action or custom validation error. So basically the dropdown lists are being reset to their default values.Some code (if missing parts, just ask and I will post them) - Don't mind the code structures etc... needs some refactoring :)Attribute I created:
[Code]....
KlantMetaData (=> Klant is Dutch for Customer ):
[Code]....
DynamicDropDownList Control I created: [Code]....
Dynamic FieldTemplate created for inserts: [Code]....
I have been trying to figure out what the proper method is to be able to have a dropdownlist on the same form that holds a number of textboxes for properties. I am using a strongly typed typed view which was generated by the Visual Studio IDE so it contains textboxes for all of the properties of my strongly typed class. The class has a few properties that can have a set of possilbe answers; I'd like to displat those possible answers in a dropdownlist and then when the user fills in the form and clicks the submit button the selected item would be transferred to the correct property. I have a solution but think there must be a better solution out there and was wondering if anyone might point me in the right direction.So say I have a model with 3 properties, FirstName, LastName. and MaritalStatus.If I generated a view for this then I'd get an aspx file with the following:
I want to do Dropdown selected index changed get data fill in textbox etc. How can I do.
string ID = drpkategori.SelectedItem.Value; using (KargocuEntities kargo = new KargocuEntities()) { var kargotakip = from t1 in kargo.KargoEkle join t2 in kargo.KargoDetay on t1.ID equals t2.KargoID where t1.GonderiNo == ID select t2;