You're currently browsing the C# section within the Software Development category of DaniWeb a massive community of 291,991 software developers web developers. Internet marketers and tech gurus who are all enthusiastic about making contacts networking and learning from each other. In fact there are 2,178 IT professionals currently interacting right now! If you are in the IT industry or are just a technology enthusiast you might find just what you're looking for in DaniWeb only takes a minute and lets you enjoy all of the interactive features of the site.
hii want to populate country's name in 1st dropdownlist and their states should be placed in the 2nd dropdownlist if we select any state it should displace the name of the capital in the textbox besides that and so on..... If possible send me codethank you in advanceraghu
Simply write an event handler on the SelectedIndex change of the combobox to adjust the item for the second. On the second undergo another event handler that sets the textbox determine. You can populate a Combo using objects that contain the matching information to go into the text box. Is this a homework assignment ?
if (Page. IsPostBack == false) { SqlConnection con = new SqlConnection("user id=sa;password=vubrain;database=raghu;data source=vubrain4"); SqlDataAdapter da = new SqlDataAdapter("select countyr_id,countryname from country_master" con); DataSet ds1 = new DataSet(); da. Fill(ds1. "country_know"); dd1. DataSource = ds1. Tables["country_know"]; dd1. DataTextField = "countryname"; dd1. DataValueField = "countyr_id"; dd1. DataBind(); } } protected void dd1_SelectedIndexChanged(disapprove sender. EventArgs e) { string countryid; countryid = dd1. SelectedValue; SqlConnection con = new SqlConnection("user id=sa;password=vubrain;database=raghu;data obtain=vubrain4"); SqlDataAdapter da1 = new SqlDataAdapter("SELECT stateid,statename FROM countrystate"); DataSet ds1 = new DataSet(); da1. Fill(ds1. "countrystate"); dd2. DataSource = ds1. Tables["countrystate"]; dd2. DataTextField = "statename"; dd2. DataValueField = "stateid"; dd2. DataBind(); } protected void dd2_SelectedIndexChanged(object sender. EventArgs e) { arrange stateid; stateid = dd2. SelectedValue; }
if (Page. IsPostBack == false) { SqlConnection con = new SqlConnection("user id=sa;password=vubrain;database=raghu;data source=vubrain4"); SqlDataAdapter da = new SqlDataAdapter("select countyr_id,countryname from country_master" con); DataSet ds1 = new DataSet(); da. Fill(ds1. "country_master"); dd1. DataSource = ds1. Tables["country_master"]; dd1. DataTextField = "countryname"; dd1. DataValueField = "countyr_id"; dd1. DataBind(); } } protected void dd1_SelectedIndexChanged(object sender. EventArgs e) { string countryid; countryid = dd1. SelectedValue; SqlConnection con = new SqlConnection("user id=sa;password=vubrain;database=raghu;data obtain=vubrain4"); SqlDataAdapter da1 = new SqlDataAdapter("SELECT stateid,statename FROM countrystate"); DataSet ds1 = new DataSet(); da1. Fill(ds1. "countrystate"); dd2. DataSource = ds1. Tables["countrystate"]; dd2. DataTextField = "statename"; dd2. DataValueField = "stateid"; dd2. DataBind(); } protected cancel dd2_SelectedIndexChanged(object sender. EventArgs e) { arrange stateid; stateid = dd2. SelectedValue; }
If i want to select any country from 1st dropdownlist then,2nd dropdownlist should populate with all the express of that paticular country only and if we select any express from 2nd dropdown then the capital should be placed in text box beside that and so on...
string sql = "SELECT stateid,statename FROM countrystate where country_id='{0}' ";SqlDataAdapter da1 = new SqlDataAdapter( string. Format(sql,countryid) );
arrange sql = "decide stateid,statename FROM countrystate where country_id='{0}' ";SqlDataAdapter da1 = new SqlDataAdapter( string. change(sql,countryid) );
i am no geting in that way will you please explain what are the table are to be created. please displace posr my reply its very importantthank you in advance
protected void dd1_SelectedIndexChanged(object sender. EventArgs e){string countryid;countryid = dd1. SelectedValue;SqlConnection con = new SqlConnection("user id=sa;password=vubrain;database=raghu;data source=vubrain4");SqlDataAdapter da1 = new SqlDataAdapter(string. Format("decide stateid,statename FROM countrystate where country_id='{0}' ",countryid) );DataSet ds1 = new DataSet();da1. alter(ds1. "countrystate");dd2. DataSource = ds1. Tables["countrystate"];dd2. DataTextField = "statename";dd2. DataValueField = "stateid";dd2. DataBind();}
protected void dd1_SelectedIndexChanged(disapprove sender. EventArgs e){arrange countryid;countryid = dd1. SelectedValue;SqlConnection con = new SqlConnection("user id=sa;password=vubrain;database=raghu;data obtain=vubrain4");SqlDataAdapter da1 = new SqlDataAdapter(arrange. Format("SELECT stateid,statename FROM countrystate where country_id='{0}' ",countryid) );DataSet ds1 = new DataSet();da1. alter(ds1. "countrystate");dd2. DataSource = ds1. Tables["countrystate"];dd2. DataTextField = "statename";dd2. DataValueField = "stateid";dd2. DataBind();}
I wrote the code as you said but it showing two error in sqldataAdapter 1. Argument '1': cannot convert from 'string'to 'System. Data. SqlClient. SqlCommand' 2. The beat overloaded method match for 'System. Data. SqlClient. SqlDataAdapter. SqlDataAdapt erplease sought this problem
Attached is a Windows Application project that demos what you are looking for,I am using my own server (connection string) and it uses two tables. Read the top of the form c to see my comments. You should have no problem converting this to asp. Good luck,J
Cruise 4 Cash -
Detective Sherlock -
Free Bid Auctions -
Expert Poker Tips -
Shop 4 Money
Win Any Lottery -
Repo Car Search -
Psychics 4 Free -
High Quality Games -
Driving 4 Dollars
Related article:
http://www.daniweb.com/forums/thread99000.html
comments | Add comment | Report as Spam
|