My Dropdownlist always take the 1st value of database

Apr 22 2016 3:37 AM
if (Session["User_Name"] == null)
{
Response.Redirect("Salon.aspx");
}
else
{
IEnumerator mc;
mc = Request.Cookies.AllKeys.GetEnumerator();
while (mc.MoveNext())
{
if (Request.Cookies[mc.Current.ToString()].HasKeys == true)
{
IEnumerator sc;
sc = Request.Cookies[mc.Current.ToString()].Value.GetEnumerator();
if (!Page.IsPostBack)
{
Wella.Visible = false;
Sebastian.Visible = false;
Nioxin.Visible = false;
illumina.Visible = false;
DropDownList1.AutoPostBack = true;
string Value = DropDownList1.SelectedValue;
lbUserName.Text = "WELCOME:: " + Session["User_Name"];
SqlConnection con = new SqlConnection(ConStr);
{
SqlCommand com = new SqlCommand("select User_Name,Company_Name from tblCompany where User_Name='" + Session["User_Name"] + "' ", con);
{
SqlDataAdapter da = new SqlDataAdapter(com);
DataSet ds = new DataSet();
da.Fill(ds);
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "Company_Name";
DropDownList1.DataValueField = "User_Name";
DropDownList1.DataBind();
DropDownList1.Items.Insert(0, new ListItem("---Select---", String.Empty));
DropDownList1.SelectedIndex = 0;
}
}
}
}
}
}

Answers (4)