protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable dt = DatabaseHelper.Retrieve(@" select BookCopy.Id, Title, ISBN, FirstName, LastName, BranchName, Out, Available from BookCopy join Book on (BookCopy.BookId = Book.Id) join Author on (Book.AuthorId = Author.Id) join Library on (BookCopy.LibraryId = Library.Id) order by Title "); BookCopies.DataSource = dt.Rows; BookCopies.DataBind(); } }
protected void BindRepeater() { DataTable bookCopiesdt; if (!listMode) { bookCopiesdt = DatabaseHelper.Retrieve(@" select BookCopy.Id, Title, ISBN, FirstName, LastName, BranchName, Out, Available from BookCopy join Book on (BookCopy.BookId = Book.Id) join Author on (Book.AuthorId = Author.Id) join Library on (BookCopy.LibraryId = Library.Id) order by Title "); } else { int libraryCardNumber = int.Parse(Context.User.Identity.Name); DataTable getLibrary = DatabaseHelper.Retrieve(@" select LibraryId from Librarian where LibraryCardNumber = @LibraryCardNumber ", new SqlParameter("@LibraryCardNumber", libraryCardNumber)); int libraryId = getLibrary.Rows[0].Field <int>("LibraryId"); bookCopiesdt = DatabaseHelper.Retrieve(@" select BookCopy.Id, Title, ISBN, FirstName, LastName, BranchName, Out, Available from BookCopy join Book on (BookCopy.BookId = Book.Id) join Author on (Book.AuthorId = Author.Id) join Library on (BookCopy.LibraryId = Library.Id) where LibraryId = @LibraryId order by Title ", new SqlParameter("@LibraryId", libraryId)); } BookCopies.DataSource = bookCopiesdt.Rows; BookCopies.DataBind(); }