protected void Address_TextChanged(object sender, EventArgs e) { if (Address.SelectedItem == null) { return; } string a = Address.SelectedItem.Value; using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { conn.Open(); SqlCommand cmd; if (_role == "ODS_tsg") { cmd = new SqlCommand("select lt.LiftId from LiftsTtx lt " + "join ODSLifts o on o.LiftId=lt.LiftId " + "join Users u on u.UserId=o.UserId " + "join Ttx tt on tt.Id=lt.TtxId " + "where tt.TtxTitleId=1 and u.UserName=@userName and tt.Ttx=@t", conn); cmd.Parameters.AddWithValue("userName", User.Identity.Name); } else { cmd = new SqlCommand("select lt.LiftId from LiftsTtx lt " + "join Ttx tt on tt.Id=lt.TtxId " + "where tt.TtxTitleId=1 and tt.Ttx=@t", conn); } cmd.Parameters.AddWithValue("t", a); List <string> lifts = new List <string>(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { lifts.Add(dr[0].ToString()); } dr.Close(); Lift.DataSource = lifts; Lift.DataBind(); Lift.SelectedIndex = 0; if (Uslugy.SelectedValue == "Эксплуатация лифтов") { NLift.Visible = true; Lift.Visible = true; NLift.Text = "Bыбрать №!"; } else { NLift.Visible = true; Lift.Visible = false; NLift.Text = "Внести!"; } } }