Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Username"] == null)
        {
            Response.Redirect("login.aspx");
        }

        StudentService service = new StudentService();

        StudentsGrid.DataSource = service.GetStudents();
        StudentsGrid.DataBind();
    }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection myconnect = new SqlConnection(WebConfigurationManager.ConnectionStrings["smsconnection"].ConnectionString);

            myconnect.Open();
            try
            {
                SqlCommand mycommand = new SqlCommand("getallstudents", myconnect);
                mycommand.CommandType = System.Data.CommandType.StoredProcedure;
                SqlDataReader myreader = mycommand.ExecuteReader();
                StudentsGrid.DataSource = myreader;
                StudentsGrid.DataBind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                myconnect.Close();
            }
        }