DropDownlist SelectedIndex Problem

Oct 10 2007 12:18 PM

I have two dropdownlists and I want to take user city and province in user profile.I write database user profile correctly but In Edit User Profile.aspx I select city index from database correctly and get provinces according to this city but Province selectedindex isnot same with index in database.This .aspx file shows 0.index item in province dropdownlist.MeanWhile DDL_Province.SelectedIndex = GetfromProvinceIndexFromDatabase(userid); // selected correctly from database

For Example; City:NewYork(index:4)  Province:Mentalli(index:2)

DDL_City.SelectedIndex = GetfromCityIndexFromDatabase(userid); (4)

DataTable Province = GetProvincesByCityIndex(DDL_City.SelectedIndex);

DDL_Province.DataSource = Province;

DDL_Province.DataTextField =
"Province";DDL_Province.DataValueField = "id";

DDL_Province.DataBind();

DDL_Province.SelectedIndex = GetfromProvinceIndexFromDatabase(userid); (2)

but DDL_Province show user 0.index item. I think this problem is occured because of DataBind(). How do I solve this problem???


Answers (1)