コード例 #1
0
ファイル: login.aspx.cs プロジェクト: OMGdadada/newMPRE
 private void MyDataBind()
 {
     using (SqlConnection conn = new DB().GetConnection())
     {
         SqlCommand cmd = conn.CreateCommand();
         cmd.CommandText = "Select * from Doctor";
         conn.Open();
         SqlDataReader rd = cmd.ExecuteReader();
         UserNameDDL.DataSource     = rd;
         UserNameDDL.DataTextField  = "DoctorName";
         UserNameDDL.DataValueField = "GUID";
         UserNameDDL.DataBind();
         rd.Close();
         UserNameDDL.Items.Insert(0, new ListItem("--请选择医生或治疗师--", "-1"));
         if (Request.Cookies["DoctorName"] != null)
         {
             string doctorname = HttpUtility.UrlDecode(Request.Cookies["DoctorName"].Value, Encoding.GetEncoding("UTF-8"));
             if (UserNameDDL.Items.FindByText(doctorname) != null)
             {
                 UserNameDDL.ClearSelection();
                 UserNameDDL.Items.FindByText(doctorname).Selected = true;
             }
         }
         conn.Close();
     }
 }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Doctor d = (Doctor)Session["doctor"];
            HelloLabel.Text = d.CDoctorName;
            Pharmcy.PharmcyWS webser = new Pharmcy.PharmcyWS();
            DataSet           ds     = webser.GetMedinceNameAndId();
            List <ListItem>   LI     = GetAllData.getListItemsForDDL(ds, "Medicine");
            foreach (ListItem l in LI)
            {
                MedicineNameDDL.Items.Add(l);
            }
            MedicineNameDDL.DataBind();

            UserService us = new UserService();
            ds = us.GetUserNameAndId();
            LI = GetAllData.getListItemsForDDL(ds, "User");
            foreach (ListItem l in LI)
            {
                UserNameDDL.Items.Add(l);
            }
            UserNameDDL.DataBind();
        }
    }