예제 #1
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["studentDBConnectionString"].ConnectionString))
         {
             con.Open();
             //Change with your select statement .
             using (SqlCommand cmd = new SqlCommand("select * from Profession", con))
             {
                 DataTable      dt   = new DataTable();
                 SqlDataAdapter adpt = new SqlDataAdapter(cmd);
                 adpt.Fill(dt);
                 Dictionary <int, string> lst = new Dictionary <int, string>();
                 foreach (DataRow row in dt.Rows)
                 {
                     //Add values to Dictionary
                     string val = row[1].ToString();
                     lst.Add(Convert.ToInt32(row[0]), val);
                 }
                 ProfessionDDL.DataSource     = lst;
                 ProfessionDDL.DataTextField  = "Value";
                 ProfessionDDL.DataValueField = "key";
                 ProfessionDDL.DataBind();
             }
         }
     }
 }
예제 #2
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["studentDBConnectionString"].ConnectionString))
            {
                con.Open();
                //Change with your select statement .
                using (SqlCommand cmd = new SqlCommand("select * from Profession", con))
                {
                    DataTable      dt   = new DataTable();
                    SqlDataAdapter adpt = new SqlDataAdapter(cmd);
                    adpt.Fill(dt);
                    Dictionary <int, string> lst = new Dictionary <int, string>();
                    foreach (DataRow row in dt.Rows)
                    {
                        //Add values to Dictionary
                        string val = row[1].ToString();
                        lst.Add(Convert.ToInt32(row[0]), val);
                    }
                    ProfessionDDL.DataSource     = lst;
                    ProfessionDDL.DataTextField  = "Value";
                    ProfessionDDL.DataValueField = "key";
                    ProfessionDDL.DataBind();
                }
            }
        }
        availabilityDS.SelectParameters.Add("current_teacher_id", idTB.Text);

        availabilityDS.SelectCommand = "select Ave_TeaId,Ave_day,Ave_startHour, Ave_endtHour, (tea_firstName + ' ' + tea_lastName) as 'teacher_full_name' from TeacheravAilability inner join Teacher on Ave_TeaId = Tea_Id where Ave_TeaId=@current_teacher_id";
    }