Anda di halaman 1dari 1

Retrieving contents 2 drop down list:

private void ddladdstate()


{
SqlCommand cmd = new SqlCommand("select * from state", cn);
SqlDataReader dr = cmd.ExecuteReader();
ddlstate.Items.Clear();
ddlstate.Items.Add("Select");
while (dr.Read())
{
ListItem li = new ListItem();
li.Value = dr["stateid"].ToString();
li.Text = dr["statename"].ToString();
ddlstate.Items.Add(li);
}
dr.Close();
}