Web Forms :: Particular Country Get Marked If Selected From Dropdownlist
Jan 3, 2010
learning asp.net and prepare my final year project. i've problem in dropdownlist hope i found answer here. I've two dropdown list each consist four listitem as follows
dropdownlist1
uk,usa,india,singapore.
dropdownlist2
uk,usa,india,singapore.
if anyone of the country selected from dropdownlist1 then dropdownlist2 that particular country automatically get masked or readomly
i have one dropdownlist in the gridview. i have to load that dropdownlist when that page is loaded. dropdownlist should contain the country list from country table
I have a country dropdown and a city dropdown.I am filling the country dropdown at the time of page load and showing the city dropdown blank. On the "onChange()" event of the country drop down I am filling the city dropdown according to the country id.
My problem is that after the postback of the page on the "onChange()" event , I am not getting the selected country name(i am getting the "--select country--"). How can i solve this problem.I am waiting for your response.
In My project I have DoupDownList(ddl). In my ddl in need to bind country names along With Country Flag..So Can Any One Help Me In thi issue...Country Name And Country Flag Bouth i need to Bind in my ddl
I'm building a WebControl for user registration. To expedite its use checks I used clientside validation through AjaxControlToolkit.ValidatorCalloutExtender. The validation is triggered when REGISTER button is pressed and popup information for missing or incorrect fields is showed. But I have a problem about a cascading dropdownlist(DDL) [Country]>>[City], because during the client-side validation I'm no more able to refresh my City DDL depending on the new selected Country. Server side, SelectedIndexChanged event is triggered but the DDL in the browser is not refreshed! (The DDL Country and City are Causevalidation=false) This occurs for each control on the page changed by server during client-side validation. How can I fix?
The 2 dropdownlist controls are-ddlCountry and ddlState. The 2 database tables are-Country and State Country table has fields named- C_ID(pk) and Country State table fields are-S_ID(pk), State, C_ID I'm able to bind the dropdownlist controls to the database. But I want the contents of ddlState to change according to the Country selected from ddlCountryI don't want to use ajax
I need a dropdown to display respective states when specific country is selected similarly for cities. I kept 3 dropdowns for country, state and city with 3 different tables with primary, foreign key constraints and stored procedures. The Stored Procedure is as shown ALTER PROCEDURE [dbo].[Usp_countryselect]
WITH EXECUTE AS CALLER AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SELECT [country_id], [country_name] FROM country Similarly for states and city.
The code for populate lists is as shown
public class PopulateLists { public int FillCountry(ref System.Web.UI.WebControls.DropDownList drpdown) { SqlDatabase db = new SqlDatabase(); DbCommand cmd=db.GetStoredProcCommand("USP_countryselect"); DataSet dsCountry= db.ExecuteDataSet(cmd); drpdown.DataSource =dsCountry.Tables[0] ; drpdown.DataTextField=dsCountry.Tables[0].Columns["country_name"].ToString() ; drpdown.DataValueField = dsCountry.Tables[0].Columns["country_id"].ToString() ; drpdown.DataBind(); return 1; } public int FillState(ref System.Web.UI.WebControls.DropDownList drpdown) { SqlDatabase db = new SqlDatabase(); DbCommand cmd = db.GetStoredProcCommand("USP_statesselect"); DataSet dsStates = db.ExecuteDataSet(cmd); drpdown.DataSource = dsStates.Tables[0]; drpdown.DataTextField = dsStates.Tables[0].Columns["state_name"].ToString(); drpdown.DataValueField = dsStates.Tables[0].Columns["state_id"].ToString(); drpdown.DataBind(); return 1; } . . . } protected void Page_Load(object sender, EventArgs e) { BindDropdowns(); } protected void BindDropdowns() { PopulateLists objPopulateLists = new PopulateLists(); int bytReturn; bytReturn = objPopulateLists.FillCountry(ref Drpcountry); bytReturn = objPopulateLists.FillState(ref Drpstate); bytReturn = objPopulateLists.FillCity(ref Drpcity); }
But in the output screen it is displaying all the values in the dropdowns irrespective of country and state selection.
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.
retrieving values related to user select a country then its automatically shows the states name of that country in next dropdownlist and after that it will automatically display the city names respected to that country.
I am developing my map function. When i click the state on country map, it should return the state name. But it didn't. I've spending a lot of time google about it and try a lot of ways to solve it. But i keep getting the JS error:"null" is null or not an object. Is it because my dropdown list having this runat="server" attribute???I don't want to delete this attribute since i am using it in my code behind.
Here is piece of my code behind for the state ddl.
[Code]....
And here is piece of my html code:
[Code]....
Then, i have multiple events for the map onclick function. Here is the code:
Using four dropdown lists (country, state, city, pincode) in one table. i want to select one after other like based upon the country, states has to be displayed and based upon the states, cities has to be displayed and based upon the cities , pincode has to display.
I have two pages manager and user both have drop downs as
Week, Months and Years.
User have to enter some data week wise for each months and Manager have to approve that.
To Approve manager select months and week from dropdown on his own page and then navigate to User page.
How does I should bind the drop down so that if manager select 1st week from it's page and goes to view link of user then in drop down of user selected value shold be the same as selected by Manager on his own page.
i am displaying various countries names in my dropdownlist and i want to display the data using gridview like whenever i change the country in my ddl it should display the relevant data according to the country??below is my code but i am unable to see any data whenever i change the country in my ddl gridview is not appearing??
This is fetching the IP address alright, but now I want to know the country of the visitor and USE that country name to redirect the visitor to some webpage accordingly.
I came across this library but have no clue how to use it in the project. Actually I do, but I am not sure so I am asking.
http://ipaddressextensions.codeplex.com/
When I download from the above the ZIP folder has a DLL file and an XML file. Now, what do I do with these two? Like include in the project. Then what do I type in the code file?
Something like the following.
if (countryName=="France") { response.redirect("www.mysite.fr") [code]....
How do I go about it? Also do I really need to type SO many if blocks for ALL the countries. How do I shorten this code?
Usually when we create an aspx page and then open the aspx.cs page we can see a protected void page_load().So my question is why that should be protected in default.Can we give other access modifiers.
I am having a problem with disabling DropDownList based on the chice of 1st DropDownList, there is no post back occuring, and it is a template based web app here is the current code:
what is happening now is page is blank and if I remove the above code everything shows, where I am going wrong. here is the plain and final javascript code which worked:
what i m trying is i hav two dropdownlists inside the gridview... namely say ddonsiteoffsite and ddhours... now what i want is if the selectedtext of ddonsiteoffsite is "onsite" the ddhours should b disabled... i tried the code snippet but ... its not disabling the ddhours... can someone help me please..
I am having a 2 dropdown list, in the first dropdown I have 3company names,for each company I am having separate tables,every table have a empcode, if the user select the company name in the 1st dropdownlist, as per company selected the 2nd dropdownlist it will fill the list of employee codes as per the selection..
I am binding months to a list 0-13 items default selection is 0 months duration, and years 0-8 items and 0 years is the default selection.As I know there are always going to be 12 months in a year, I could use selectedvalue or selectedindex without any perceived problem. Is there a reason why I should not use either/or of the two properties to select a list item?
My problem is I need to set selected value of a drop down list to a value I retreive from a database. The example only has a know value.
Below is the HTML and Code. <asp:DropDownList id="ddlCatogory1st1" DataSourceID="srcCatogory1st1" DataTextField="CategoryName" DataValueField="CategoryID" AutoPostBack="true" Runat="server" /> <asp:sqldatasource id="srcCatogory1st1" ConnectionString="server=(local);database=db;Trusted_Connection=true" SelectCommand="SELECT CategoryID, CategoryName FROM Categories WHERE ParentCategoryID is null ORDER BY CategoryID" Runat="server" ></asp:sqldatasource> Sub Page_Load() DISPLAY_CATEGORY() End Sub Sub DISPLAY_CATEGORY() ddlCatogory1st1.DataBind() ddlCatogory1st1.Items.FindByValue("A").Selected = True End Sub
When I run this page I get
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 222: Line 223: Sub DISPLAY_CATEGORY() Line 224: ddlCatogory1st1.DataBind() Line 225: ddlCatogory1st1.Items.FindByValue("A10").Selected = True Line 226: End Sub
Even if I take out the databind I get the same error.