i m using two dropdown box one for country and other for state.i want that when i will select any country from dropdown box then its related state will display in other dropdown box.
RSS
i m using two dropdown box one for country and other for state.i want that when i will select any country from dropdown box then its related state will display in other dropdown box.
1) you can hit the database on the selectedIndexChange event of the COuntry dropdown and retrieve the corresponding state by passin g the counttry id or country name
I hope you have Country and State master tables.
Country table having country id and Contry name.
State table having State Id, State Name and corresponding Country Id.
1. First bind the all country in Country Drop down (Country id in Value data Name as text data)
2. Write the code in Country dropdown selected index chage event for which country chosen to get the state list and bind in this to state dropdown.
santosh22526...
Member
9 Points
36 Posts
i m using two dropdown box one for country and other for state.i want that when i will select any...
Feb 20, 2012 03:22 AM|LINK
i m using two dropdown box one for country and other for state.i want that when i will select any country from dropdown box then its related state will display in other dropdown box.
im using c# asp.net
plz help me.....
georgemathew...
Member
40 Points
20 Posts
Re: i m using two dropdown box one for country and other for state.i want that when i will select...
Feb 20, 2012 03:56 AM|LINK
hi,
1) you can hit the database on the selectedIndexChange event of the COuntry dropdown and retrieve the corresponding state by passin g the counttry id or country name
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList2.DataSource = dt;
DropDownList2.DataBind();
}.
2) you can use jquey ajax for retrieving the statelist from the database
var populateStates = function (sourceddl, targetddl) {
$.ajax({
type: "GET",
url: "../populatestates.aspx",
data: "reqMode=states&cid=" + sourceddl.val(),
contentType: "text/plain",
dataType: "text",
success: function (text) {
targetddl.get(0).options.length = 0;
targetddl.get(0).options[0] = new Option("Select One", "-1");
var msg = jQuery.parseJSON(text);
$.each(msg, function (index, item) {
targetddl.get(0).options[targetddl.get(0).options.length] = new Option(item.StateName, item.StateName + "@" + item.StateId);
});
},
error: function () {
}
});
}
in PopulateStates.aspx, write function to populate the state dropdown
vendan
Participant
856 Points
293 Posts
Re: i m using two dropdown box one for country and other for state.i want that when i will select...
Feb 20, 2012 04:04 AM|LINK
Hi,
I hope you have Country and State master tables.
Country table having country id and Contry name.
State table having State Id, State Name and corresponding Country Id.
1. First bind the all country in Country Drop down (Country id in Value data Name as text data)
2. Write the code in Country dropdown selected index chage event for which country chosen to get the state list and bind in this to state dropdown.
Kalaivendan
Please Mark as Answer if this post helps you!
chetan.sarod...
All-Star
65749 Points
11148 Posts
Re: i m using two dropdown box one for country and other for state.i want that when i will select...
Feb 21, 2012 02:19 AM|LINK
Hi, Please refer this
http://beyondrelational.com/blogs/niladribiswas/archive/2011/07/29/cascading-drop-down-example-country-state-and-city-in-jquery.aspx
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.