-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallBks.aspx.cs
More file actions
79 lines (68 loc) · 2.47 KB
/
allBks.aspx.cs
File metadata and controls
79 lines (68 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
namespace Assignment3
{
public partial class allBks : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
booksTable.CssClass = "table table-hover";
TableRow tRow = new TableRow();
booksTable.Rows.Add(tRow);
TableCell tCell1 = new TableCell();
TableCell tCell2 = new TableCell();
TableCell tCell3 = new TableCell();
tCell1.Text = "Title";
tCell2.Text = "Author";
tCell3.Text = "ISBN";
tRow.Cells.Add(tCell1);
tRow.Cells.Add(tCell2);
tRow.Cells.Add(tCell3);
string connStr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
string sql = "select BookTitle, BookAuthor, ISBN, BookId from Book";
SqlConnection con = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataReader dr;
try
{
con.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
TableRow tRow2 = new TableRow();
booksTable.Rows.Add(tRow2);
for (int j = 0; j <= 2; j++)
{
// Create a new cell and add it to the row.
TableCell tCell = new TableCell();
tCell.Text = dr[j].ToString();
tRow2.Cells.Add(tCell);
}
if (Session["id"] != null)
{
TableCell tCell4 = new TableCell();
string id = dr[3].ToString();
tCell4.Text = "<a href='default.aspx?id=" + id + "'><span class='btn btn-primary glyphicon glyphicon-cloud-download'>Borrow </span></a>";
tRow2.Cells.Add(tCell4);
}
}
dr.Close();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
finally
{
con.Close();
}
}
}
}