TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Khargesh Rajput
NA
5.6k
603k
how to select cities in listbox on dropdownlist index change
Jul 31 2013 9:44 PM
I have a dropdownlist for states.
and on selected index change i want the cities of the selected state in listbox.
I have bind states in dropdownlist, but on selected index chnge i got only default value.
public void bindstate()
{
DataSet ds = new DataSet();
ds = objdal.FillDataSet(CommandType.Text, "select * from state where active=1");
//ddlstate.Items.Clear();
//ddlstate.Items.Add("Select State");
ddlstate.DataTextField = "statename";
ddlstate.DataValueField = "StateId";
ddlstate.DataSource = ds.Tables[0];
ddlstate.DataBind();
ddlstate.Items.Insert(0, new ListItem("-- Select State --", "0"));
and
DataSet ds = new DataSet();
ds = objdal.FillDataSet(CommandType.Text, "select City_Name from City where State_id='"+ddlstate.SelectedValue+"'");
listcity.DataSource = ds.Tables["City"];
listcity.DataTextField = "City_name";
listcity.DataValueField = "CityID";
listcity.DataBind();
listcity.Items.Insert(0,new ListItem("select city","0"));
obkdal is object of DAL
Reply
Answers (
3
)
Delete selected data from gridview and table in sqlserver
Display database timestamp in YYYY-MM-DD hh:mm:ss format