protected void GridViewTeacher_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = Convert.ToInt32(e.CommandArgument.ToString()); string id = this.GridViewTeacher.DataKeys[rowIndex]["Id"].ToString(); if (e.CommandName == "updates") { ListToTable lsttodt = new ListToTable(); var lst = teacherRepository.GetTeacherListByID(Convert.ToInt32(id)); DataTable dt = lsttodt.ToDataTable(lst); if (dt != null && dt.Rows.Count > 0) { txtId.Text = dt.Rows[0]["Id"].ToString(); txtTeacherName.Text = dt.Rows[0]["TeacherName"].ToString(); txtQualification.Text = dt.Rows[0]["Qualification"].ToString(); btnSave.Text = "Update"; } else { //do nothing btnSave.Text = "Save"; } } else { DataTable dt = new DataTable(); bool result = teacherRepository.DeletesTeacher(Convert.ToInt32(id)); if (result) { bindGrid(); } } }
protected void GridViewCourse_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = Convert.ToInt32(e.CommandArgument.ToString()); string courseid = this.GridViewCourse.DataKeys[rowIndex]["Id"].ToString(); if (e.CommandName == "updates") { ListToTable lsttodt = new ListToTable(); var lst = courseRepository.GetCourseListByID(Convert.ToInt32(courseid)); DataTable dt = lsttodt.ToDataTable(lst); if (dt != null && dt.Rows.Count > 0) { txtCourseId.Text = dt.Rows[0]["Id"].ToString(); txtCourseName.Text = dt.Rows[0]["CourseName"].ToString(); txtFees.Text = dt.Rows[0]["CourseFees"].ToString(); txtTime.Text = dt.Rows[0]["CourseDuration"].ToString(); btnSave.Text = "Update"; } else { //do nothing btnSave.Text = "Save"; } } else { DataTable dt = new DataTable(); bool result = courseRepository.DeletesCourse(Convert.ToInt32(courseid)); if (result) { bindGrid(); } } }
protected void bindGrid() { ListToTable lsttodt = new ListToTable(); var lst = teacherRepository.GetTeacherList(); DataTable dt = lsttodt.ToDataTable(lst); if (dt != null && dt.Rows.Count > 0) { GridViewTeacher.DataSource = dt; GridViewTeacher.DataBind(); } else { GridViewTeacher.DataBind(); } }
protected void bindGrid()//method for binding gridview { ListToTable lsttodt = new ListToTable(); var lst = courseRepository.GetCourseList(); DataTable dt = lsttodt.ToDataTable(lst); if (dt != null && dt.Rows.Count > 0) { GridViewCourse.DataSource = dt; GridViewCourse.DataBind(); } else { GridViewCourse.DataBind(); } }
protected void bindTeacherList() { ListToTable lsttodt = new ListToTable(); ITeacherRepository courseRepository = new TeacherRepository(); var lst = courseRepository.GetTeacherList().Select(x => new { x.TeacherName, x.Id }).ToList(); DataTable dt = lsttodt.ToDataTable(lst); if (dt != null && dt.Rows.Count > 0) { ddTeacher.DataSource = dt; ddTeacher.DataTextField = "TeacherName"; ddTeacher.DataValueField = "Id"; ddTeacher.DataBind(); } else { ddTeacher.DataBind(); } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = Convert.ToInt32(e.CommandArgument.ToString()); string id = this.GridView1.DataKeys[rowIndex]["Id"].ToString(); if (e.CommandName == "updates") { ListToTable lsttodt = new ListToTable(); var lst = studentRepository.GetStudentListByID(Convert.ToInt32(id)); DataTable dt = lsttodt.ToDataTable(lst); if (dt != null && dt.Rows.Count > 0) { txtId.Text = dt.Rows[0]["Id"].ToString(); txtStdName.Text = dt.Rows[0]["StdName"].ToString(); txtAddress.Text = dt.Rows[0]["Address"].ToString(); txtFather.Text = dt.Rows[0]["FatherName"].ToString(); txtEmail.Text = dt.Rows[0]["Email"].ToString(); txtMobile.Text = dt.Rows[0]["Mobile"].ToString(); ddCourse.SelectedValue = dt.Rows[0]["CourseId"].ToString(); ddTeacher.SelectedValue = dt.Rows[0]["TeacherId"].ToString(); btnSave.Text = "Update"; } else { //do nothing btnSave.Text = "Save"; } } else { DataTable dt = new DataTable(); bool result = studentRepository.DeletesStudent(Convert.ToInt32(id)); if (result) { bindGrid(); } } }