Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Page.User.Identity.IsAuthenticated)
            {
                DataSet ds = dbws.selectQuestions();
                // gvChoices.DataSource = ds;
                // gvChoices.DataBind();

                DataSet dsSubjects = dbws.selectAllSubjects();
                SubjectDropDownList.DataSource     = dsSubjects;
                SubjectDropDownList.DataTextField  = "SubjectName";
                SubjectDropDownList.DataValueField = "SubjectID";
                SubjectDropDownList.DataBind();

                DataSet dsQuestions = dbws.selectAllQuestions();
                allQuestionsDropDownList.DataSource     = dsQuestions;
                allQuestionsDropDownList.DataTextField  = "QuestionText";
                allQuestionsDropDownList.DataValueField = "QuestionID";
                allQuestionsDropDownList.DataBind();
            }
            else
            {
                Response.Redirect("LoginPage.aspx");
            }
        }
    }
Пример #2
0
    public void PopulateSubjects()
    {
        string uid = Session["uid"].ToString();

        cmd = new SqlCommand("select subject from subjects join teaches on subjects.subid=teaches.subid where uid=@uid", con);
        cmd.Parameters.AddWithValue("@uid", uid);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet        ds = new DataSet();

        da.Fill(ds);
        SubjectDropDownList.DataSource     = ds;
        SubjectDropDownList.DataValueField = "subject";
        SubjectDropDownList.DataBind();
    }