protected void Page_Load(object sender, EventArgs e)
{
Response.Write(Session["email"].ToString());
SqlConnection conn = new SqlConnection(dbConnectionString);
conn.Open();
string query = "select * from country";
SqlCommand cmd = new SqlCommand(query,conn);
SqlDataReader dr = cmd.ExecuteReader();
drpdown_country.Items.Add(new ListItem("---select---", "0"));
if (dr.HasRows)
{
while (dr.Read())
{
drpdown_country.Items.Add(new ListItem(dr["country"].ToString(), dr["c_id"].ToString()));
}
}
conn.Close();
}
每当我运行此代码并刷新页面
时,它都会再次显示所有 Countrynames
因此,当我刷新时,我获得的单个国家/地区名称的次数