When user will login first time then user will fill his profile details and when he login next time then all the filled details will be shown to the user by fetching from database and user can update particular value.. but value of state and city is being fetched in code behind but it is not setting the value in dropdownlist. why?
help me please.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
mycon.Open();
cmd.Connection = mycon;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select Name,email from Common_regn2 where email='" + Session["mail"].ToString() + "'";
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
cname.Text = dr["Name"].ToString();
cname.ReadOnly = true;
txt_mail.Text = dr["email"].ToString();
txt_mail.ReadOnly = true;
}
}
Session["name"] = cname.Text.ToString();
}
if (!IsPostBack)
{
mycon.Close();
mycon.Open();
cmd.Connection = mycon;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select City,State,phone,Contact_person,Address,Company_website from Company_profile where email='" + Session["mail"].ToString() + "'";
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
State.SelectedItem.Value = dr["State"].ToString();
city.SelectedItem.Text = dr["City"].ToString();
txt_no.Text = dr["phone"].ToString();
txt_Contact.Text = dr["Contact_person"].ToString();
txt_address.Text = dr["Address"].ToString();
weblink.Text = dr["Company_website"].ToString();
btnsave.Visible = false;
btnUpdate.Visible = true;
}
}
}
}
protected void State_SelectedIndexChanged(object sender, EventArgs e)
{
Session["sid"] = State.SelectedValue.ToString();
}