Hi
I have 2 dropdownlist
1-ddlstate
2-ddlcity
when users select Item from ddlstate according to their selected Item from ddlstate,ddlcity bind from database
below is ddlstate_onselectedindexchanged event
protected void ddlstate_OnSelectedIndexChanged(object sender, EventArgs e)
{
Bindcity();
}
and in page_load event I put below code
ListItem ItemC = DDLcity.Items.FindByText(_dr["City"].ToString());
if (ItemC != null)
{
ItemC.Selected = true;
}
ListItem ItemS = DDLstate.Items.FindByText(_dr["State"].ToString());
if (Items != null)
{
ItemS.Selected = true;
}
this mean that if there was any data in database it will show in dropdownlist
below are table
House_info
Id
|
Name
|
Behcode
|
State
|
ciry
|
1
|
Neda
|
1111
|
tehran
|
Andishe
|
and City table
id
|
State
|
city
|
1
|
Tehran
|
Tehran
|
2
|
Tehran
|
Andishe
|
3
|
Mumbai
|
Mumbai
|
4
|
Mumbai
|
ahmedabad
|
now here according to House_info table in ddlstate will shows (Tehran)
and in ddlcity will shows (Andishe)
I want if in ddlstate shows Tehran according to City table in ddlcity bind all city that state's are Tehran
I mean I want here ddlcity's Items be (Tehran,andishe== according to city table)
but here ddlcity's Item are(tehran-andisghe-Mumbai-ahmedabad)
I test below code
if (!IsPostBack)
{
bindcity():
}
but when I add above code it bind ddlcity from database but it didn't show data that is in city column in house_info table...
Best Regards
Neda
protected void DDlstate_SelectedIndexChanged(object sender, EventArgs e)
{
Bindcity();
}