Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Hashtable ht = new Hashtable();
            ht.Add(2, 345);
            ht.Add("tt", "tyyy");

            foreach (DictionaryEntry d in ht)
            {
                Response.Write(d.Key + " " + d.Value);

                Response.Write("<br>");
            }

            con.Open();
            SqlCommand    cmd = new SqlCommand("select distinct(city) from del_instructor order by city", con);
            SqlDataReader rdr = cmd.ExecuteReader();

            DrpUser.DataSource     = rdr;
            DrpUser.DataValueField = "city";
            DrpUser.DataTextField  = "city";
            DrpUser.DataBind();

            rdr.Close();
        }
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        UserDetails usr = new UserDetails();

        con.Open();
        SqlCommand cmd = new SqlCommand("select * from Del_User", con);

        SqlDataReader rdr = cmd.ExecuteReader();

        DrpUser.DataTextField  = "FirstName";
        DrpUser.DataValueField = "UserPk";
        DrpUser.DataSource     = rdr;
        DrpUser.DataBind();


        rdr.Close();



        SqlCommand    cmd1 = new SqlCommand("select * from Del_Instructor", con);
        SqlDataReader rdr1 = cmd1.ExecuteReader();

        DrpIns.DataTextField  = "InstructorName";
        DrpIns.DataValueField = "InstructorPk";
        DrpIns.DataSource     = rdr1;
        DrpIns.DataBind();


        //DrpIns.DataTextField = "FirstName";
        //DrpIns.DataValueField = "UserPk";
        //DrpIns.DataSource = rdr;
        //DrpIns.DataBind();



        //SqlConnection con = new SqlConnection("data source=HP;initial catalog=Del_Scheduling_Tool;integrated security=SSPI");
        //SqlCommand cmd = new SqlCommand("select * from del_User", con);

        //con.Open();
        //SqlDataReader rdr = cmd.ExecuteReader();

        //grdTest.DataSource = rdr;
        //grdTest.DataBind();

        //con.Close();
    }
Exemplo n.º 3
0
        protected void DrpGetuser()
        {
            SqlCommand cmd = new SqlCommand("select * from MTDUsers", con);

            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da = new SqlDataAdapter();

            da.SelectCommand = cmd;
            DataSet ds = new DataSet();

            da.Fill(ds);
            if (ds.Tables.Contains("Table") == true)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DrpUser.DataSource     = ds.Tables[0];
                    DrpUser.DataTextField  = ds.Tables[0].Columns[1].ColumnName;
                    DrpUser.DataValueField = ds.Tables[0].Columns[0].ColumnName;
                    DrpUser.DataBind();
                }
            }
        }