StudentListPage.aspx.cs


Dosyayı İndir
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;

namespace WebProject
{
  public partial class StudentListPage : System.Web.UI.Page
  {
    protected void Page_Load(object sender, EventArgs e)
    {
      string connectionString = "server=localhost;DataBase=CourseDatabase;uid=sa;pwd=godoro";
      SqlConnection connection = new SqlConnection(connectionString);
      connection.Open();

      String sql = "select * from Student";
      SqlCommand command = new SqlCommand(sql, connection);
      SqlDataReader reader = command.ExecuteReader();
      StudentTable.Caption = "ÖĞRENCİLER";
      while (reader.Read()) {
        int studentId = (int)reader["StudentId"];
        string firstName = (string)reader["FirstName"];
        string lastName = (string)reader["LastName"];
        DateTime birthDate = (DateTime)reader["BirthDate"];
        bool isGraduated = (bool)reader["IsGraduated"];
        double bodyWeight = (double)reader["BodyWeight"];
        int gradeNumber = (int)reader["GradeNumber"];

        TableRow row = new TableRow();
        
        TableCell studentIdCell = new TableCell();
        studentIdCell.Text = studentId.ToString();
        row.Cells.Add(studentIdCell);

        //TableCell firstNameCell = new TableCell();
        //firstNameCell.Text = firstName;
        //row.Cells.Add(firstNameCell);
  
        //TableCell lastNameCell = new TableCell();
        //lastNameCell.Text = lastName;
        //row.Cells.Add(lastNameCell);

        TableCell updateStudentCell = new TableCell();
        HyperLink updateStudentLink = new HyperLink();
        updateStudentLink.NavigateUrl = "StudentUpdatePage.aspx?StudentId=" + studentId.ToString();
        updateStudentLink.Text = firstName + " " + lastName;
        updateStudentCell.Controls.Add(updateStudentLink);
        row.Cells.Add(updateStudentCell);



        TableCell birthDateCell = new TableCell();
        birthDateCell.Text=birthDate.ToShortDateString();
        row.Cells.Add(birthDateCell);

        TableCell deleteStudentCell = new TableCell();
        HyperLink deleteStudentLink = new HyperLink();
        deleteStudentLink.NavigateUrl = "StudentDeletePage.aspx?StudentId=" + studentId.ToString();
        deleteStudentLink.Text = "Sil";
        deleteStudentCell.Controls.Add(deleteStudentLink);
        row.Cells.Add(deleteStudentCell);

        StudentTable.Rows.Add(row);

      }
      reader.Close();

      connection.Close();  
    }

    protected void CancelButton_Click(object sender, EventArgs e)
    {
      Response.Redirect("Default.aspx");
    }
  }
}

				
Dosyayı İndir

Bu Sayfayı Paylaş:




Bu Sayfayı Paylaş:

İletişim Bilgileri

Takip Et

Her Hakkı Saklıdır. Bu sitede yayınlanan tüm bilgi ve fikirlerin kullanımından fibiler.com sorumlu değildir. Bu sitede üretilmiş , derlenmiş içerikleri, fibiler.com'u kaynak göstermek koşuluyla kendi sitenizde kullanılabilirsiniz. Ancak telif hakkı olan içeriklerin hakları sahiplerine aittir