public StudentDataSource GetStudents(int pc) { StudentDataSource std = new StudentDataSource(); std.Pages = new List <int>(); for (int i = 1; i <= _dbContext.Students.Count() / 10; i++) { std.Pages.Add(i); } var studentsFromDb = (from s in _dbContext.Students join sc in _dbContext.StudentCourse on s.Id equals sc.StudentId into stc select new StudentDTO() { Id = s.Id, Name = s.Name, Age = s.Age, Courses = (from mc in stc join c in _dbContext.Courses on mc.CourseId equals c.Id select new CourseDTO() { Name = c.CourseName, Id = c.Id, IsChecked = true }).ToList() }).Skip(pc * 10).Take(10); std.Students = studentsFromDb; return(std); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataView studentDataView = (DataView)StudentDataSource.Select(DataSourceSelectArguments.Empty); foreach (DataRowView dvr in studentDataView) { TxtFirstName.Text = dvr["FirstName"].ToString(); TxtLastName.Text = dvr["LastName"].ToString(); TxtContact.Text = dvr["Contact"].ToString(); TxtEmail.Text = dvr["Email"].ToString(); TxtAddress.Text = dvr["Address"].ToString(); TxtBatch.Text = dvr["BatchName"].ToString(); TxtDepartment.Text = dvr["DepartmentName"].ToString(); TxtRollNum.Text = dvr["RollNo"].ToString(); if (dvr["Gender"].ToString() == "Female") { DDGender.SelectedIndex = 1; } if (dvr["Avatar"].ToString() != "") { DisplayPicture.ImageUrl = dvr["Avatar"].ToString(); } } } }
protected void Page_Load(object sender, EventArgs e) { //setting a user instance based on query string or session variable if (Request.QueryString["id"] != null) { student = Membership.GetUser(Request.QueryString["id"].ToString()); } else { student = Membership.GetUser(User.Identity.Name); } studentId = (Guid)student.ProviderUserKey; string connection = ConfigurationManager.ConnectionStrings["EIMSConnectionString"].ConnectionString; sqlcon = new SqlConnection(connection); if (!IsPostBack) { string userName; //setting the userName variable based on query string or user name value in the session if (Request.QueryString["id"] != null) { userName = Request.QueryString["id"].ToString(); } else { userName = User.Identity.Name; } //iterating through the data view and setting the fields in the form StudentUserName.Text = userName; DataView dvSql = (DataView)StudentDataSource.Select(DataSourceSelectArguments.Empty); foreach (DataRowView drvSql in dvSql) { StudentName.Text = drvSql["Name"].ToString(); StudentDepartment.Text = drvSql["DepartmentName"].ToString(); StudentBatch.Text = drvSql["BatchName"].ToString(); StudentContact.Text = drvSql["Contact"].ToString(); StudentRollNum.Text = drvSql["RollNo"].ToString(); StudentEmail.Text = drvSql["Email"].ToString(); if (drvSql["Avatar"].ToString() != "") { UserPicture.ImageUrl = drvSql["Avatar"].ToString(); } } //iterating through the parent association data view to show the parent if found DataView dvSql2 = (DataView)AssociationDataSource.Select(DataSourceSelectArguments.Empty); foreach (DataRowView drvSql in dvSql2) { //checking if a record is present in the data view, then show the associated parent if (drvSql["ParentId"].ToString() != "") { ShowAssociationPanel.Visible = true; CreateAssociationPanel.Visible = false; AssociationMessage.Text = "You have a parent account"; parent = Membership.GetUser(drvSql["ParentId"]); ParentLink.NavigateUrl = "~/Shared/ParentProfile.aspx?id=" + parent.UserName.ToString(); ParentLink.Text = parent.Email + "(" + parent.UserName + ")"; } } } }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { string strFirstName = Request.QueryString["firstname"]; string strLastName = Request.QueryString["lastname"]; string strDOB = Request.QueryString["dob"]; string strQryDupStudent; strQryDupStudent = "SELECT studentid,firstname,lastname,dob FROM student " + "WHERE ((firstname='" + strFirstName + "' OR lastname='" + strLastName + "') " + "OR(firstname='" + strLastName + "' OR lastname='" + strFirstName + "'))" + "AND(dob='" + strDOB + "')"; StudentDataSource.SelectCommand = strQryDupStudent; StudentDataSource.DataBind(); dgStudent.DataBind(); } }
protected void btnBrowseSID_Click(object sender, EventArgs e) { tblEntryForm.Visible = false; string firstname = txtFirstName.Text.Trim(); string lastname = txtLastName.Text.Trim(); if (!firstname.Length.Equals(0) || !lastname.Length.Equals(0)) { StudentDataSource.SelectCommand = DetermineQuery(firstname, lastname); } else { StudentDataSource.SelectCommand = "SELECT s.studentid,s.firstname,s.lastname,s.dob,s.lastupdatetime,c.countryname " + "FROM student s,country c WHERE s.countryid=c.countryid ORDER BY s.lastupdatetime DESC"; } StudentDataSource.DataBind(); dgStudent.Visible = true; }
protected void btnAdd_click(object sender, EventArgs e) { StudentDataSource.Insert(); }