01.
Imports
System.Data
02.
Imports
System.Data.SqlClient
03.
Partial
Class
Admin_Productlist
04.
Inherits
System.Web.UI.Page
05.
Dim
objConn
As
SqlConnection
06.
Dim
objCmd
As
SqlCommand
07.
08.
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
09.
Dim
strConnString
As
String
10.
strConnString =
"Server=localhost;UID=sa;PASSWORD=30011991;database=db_JSPJ;Max Pool Size=400;Connect Timeout=600;"
11.
objConn =
New
SqlConnection(strConnString)
12.
objConn.Open()
13.
14.
BindData()
15.
End
Sub
16.
Protected
Sub
BindData()
17.
Dim
strSQL
As
String
18.
strSQL =
"SELECT * FROM Product ORDER BY p_code "
19.
20.
Dim
dtReader
As
SqlDataReader
21.
objCmd =
New
SqlCommand(strSQL, objConn)
22.
dtReader = objCmd.ExecuteReader()
23.
24.
25.
dgvPro.DataSource = dtReader
26.
dgvPro.DataBind()
27.
28.
dtReader.Close()
29.
dtReader =
Nothing
30.
31.
End
Sub
32.
33.
Protected
Sub
Page_Unload(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Unload
34.
objConn.Close()
35.
objConn =
Nothing
36.
End
Sub
37.
38.
Protected
Sub
dgvPro_RowDataBound(
ByVal
sender
As
Object
,
ByVal
e
As
System.Web.UI.WebControls.GridViewRowEventArgs)
Handles
dgvPro.RowDataBound
39.
40.
Dim
lblid
As
Label =
DirectCast
(e.Row.FindControl(
"lblid"
), Label)
41.
If
Not
IsNothing(lblid)
Then
42.
lblid.Text = e.Row.DataItem(
"p_id"
)
43.
End
If
44.
45.
Dim
lblbrand
As
Label =
DirectCast
(e.Row.FindControl(
"lblbrand"
), Label)
46.
If
Not
IsNothing(lblbrand)
Then
47.
lblbrand.Text = e.Row.DataItem(
"p_brand"
)
48.
End
If
49.
50.
Dim
lblgen
As
Label =
DirectCast
(e.Row.FindControl(
"lblgen"
), Label)
51.
If
Not
IsNothing(lblgen)
Then
52.
lblgen.Text = e.Row.DataItem(
"p_generat"
)
53.
End
If
54.
55.
Dim
lbldetail
As
Label =
DirectCast
(e.Row.FindControl(
"lbldetail"
), Label)
56.
If
Not
IsNothing(lbldetail)
Then
57.
lbldetail.Text = e.Row.DataItem(
"p_detail"
)
58.
End
If
59.
60.
Dim
lblcate
As
Label =
DirectCast
(e.Row.FindControl(
"lblcate"
), Label)
61.
If
Not
IsNothing(lblcate)
Then
62.
lblcate.Text = e.Row.DataItem(
"cate_id"
)
63.
End
If
64.
65.
Dim
lbltotal
As
Label =
DirectCast
(e.Row.FindControl(
"lbltotal"
), Label)
66.
If
Not
IsNothing(lbltotal)
Then
67.
lbltotal.Text = e.Row.DataItem(
"p_total"
)
68.
End
If
69.
70.
Dim
lblprice
As
Label =
DirectCast
(e.Row.FindControl(
"lblprice"
), Label)
71.
If
Not
IsNothing(lblprice)
Then
72.
lblprice.Text = e.Row.DataItem(
"p_price"
)
73.
End
If
74.
75.
76.
Dim
ImgPic
As
Image =
DirectCast
(e.Row.FindControl(
"ImgPic"
), Image)
77.
If
Not
IsNothing(ImgPic)
Then
78.
ImgPic.ImageUrl =
"ViewImg.aspx?p_code= "
& e.Row.DataItem(
"p_code"
)
79.
End
If
80.
81.
82.
Dim
hplEdit
As
HyperLink =
DirectCast
(e.Row.FindControl(
"hplEdit"
), HyperLink)
83.
If
Not
IsNothing(hplEdit)
Then
84.
hplEdit.Text =
"Edit"
85.
hplEdit.NavigateUrl =
"EditPro.aspx?p_code="
& e.Row.DataItem(
"p_code"
)
86.
End
If
87.
End
Sub
88.
89.
End
Class