Hi ,
you can use this for bind data to your dropdownlist
if (!IsPostBack)
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["PersonTest"].ConnectionString))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand("SELECT CityName , id FROM City", conn))
{
DataTable dt = new DataTable();
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
adpt.Fill(dt);
DropCity.DataTextField = "CityName";
DropCity.DataValueField = "id";
}
}
}
and for select the value of dropdownlist you can use
SelectedValue
Best Regards
M.Mitwalli