001.
<%@ Import
Namespace
=
"System.Data"
%>
002.
<%@ Import
Namespace
=
"System.Data.SqlClient"
%>
003.
<%@Import
Namespace
=
"System.IO"
%>
004.
<%@Import
Namespace
=
"System.Timers"
%>
005.
<%@ Page Language=
"VB"
%>
006.
007.
<%@ Register
Assembly
=
"System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
008.
Namespace
=
"System.Web.UI"
TagPrefix=
"asp"
%>
009.
<script runat=
"server"
>
010.
011.
Dim
objConn
As
SqlConnection
012.
Dim
objCmd
As
SqlCommand
013.
014.
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
015.
Dim
strConnString
As
String
016.
strConnString =
"Server=localhost;UID=sa;PASSWORD=xxxx;database=blooddb;Max Pool Size=400;Connect Timeout=600;"
017.
objConn =
New
SqlConnection(strConnString)
018.
objConn.Open()
019.
litFullLoad.Text = System.DateTime.Now.ToString()
020.
BindData()
021.
End
Sub
022.
023.
Sub
IntervalTimer_Tick(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
024.
025.
litrptRefresh.Text =
"Repeater data will refreshed at: "
+ DateTime.Now.ToLongTimeString()
026.
027.
End
Sub
028.
029.
Sub
BindData()
030.
Dim
strSQL
As
String
031.
strSQL =
"SELECT M.HospitalName,C.BloodGroup,C.Quantity,C.Urgency FROM checkmember M INNER JOIN CallEmerge C ON M.Username = C.Username ORDER BY Urgency ASC"
032.
033.
Dim
dtReader
As
SqlDataReader
034.
objCmd =
New
SqlCommand(strSQL, objConn)
035.
dtReader = objCmd.ExecuteReader()
036.
037.
038.
myRepeater.DataSource = dtReader
039.
myRepeater.DataBind()
040.
041.
dtReader.Close()
042.
dtReader =
Nothing
043.
044.
End
Sub
045.
046.
Sub
myRepeater_ItemCommand(
ByVal
source
As
Object
,
ByVal
e
As
RepeaterCommandEventArgs)
Handles
myRepeater.ItemCommand
047.
If
e.CommandName =
"Click"
Then
048.
Dim
lblHospital
As
Label =
CType
(e.Item.FindControl(
"lblHospital"
), Label)
049.
Session(
"HospitalName"
) = lblHospital.Text
051.
End
If
052.
End
Sub
053.
054.
055.
Sub
myRepeater_ItemDataBound(
ByVal
sender
As
Object
,
ByVal
e
As
RepeaterItemEventArgs)
Handles
myRepeater.ItemDataBound
056.
057.
058.
Dim
lblHospital
As
Label =
CType
(e.Item.FindControl(
"lblHospital"
), Label)
059.
If
Not
IsNothing(lblHospital)
Then
060.
lblHospital.Text = e.Item.DataItem(
"HospitalName"
)
061.
062.
End
If
063.
064.
065.
Dim
lblBloodGroup
As
Label =
CType
(e.Item.FindControl(
"lblBloodGroup"
), Label)
066.
If
Not
IsNothing(lblBloodGroup)
Then
067.
lblBloodGroup.Text = e.Item.DataItem(
"BloodGroup"
)
068.
End
If
069.
070.
071.
Dim
lblQuantity
As
Label =
CType
(e.Item.FindControl(
"lblQuantity"
), Label)
072.
If
Not
IsNothing(lblQuantity)
Then
073.
lblQuantity.Text = e.Item.DataItem(
"Quantity"
)
074.
End
If
075.
076.
077.
078.
Dim
lnkContact
As
LinkButton =
CType
(e.Item.FindControl(
"lnkContact"
), LinkButton)
079.
If
Not
IsNothing(lnkContact)
Then
080.
lnkContact.Attributes.Add(
"OnClick"
,
"return confirm('Delete Record?');"
)
081.
End
If
082.
083.
084.
End
Sub
085.
086.
087.
088.
</script>
089.
091.
<head id=
"Head1"
runat=
"server"
>
092.
<title>Untitled Page</title>
093.
</head>
094.
<body>
095.
<form id=
"form1"
runat=
"server"
>
096.
097.
Time
When
Full Page Load:
098.
099.
<asp:Literal ID=
"litFullLoad"
runat=
"server"
></asp:Literal><br />
100.
101.
<br />
102.
103.
<asp:ScriptManager ID=
"scManager"
runat=
"server"
></asp:ScriptManager>
104.
105.
<div>
106.
107.
<asp:Timer ID=
"IntervalTimer"
OnTick=
"IntervalTimer_Tick"
runat=
"server"
Interval=
"15000"
>
108.
109.
</asp:Timer>
110.
111.
</div>
112.
113.
<asp:UpdatePanel ID=
"upPanel"
UpdateMode=
"Conditional"
runat=
"server"
>
114.
<Triggers>
115.
116.
<asp:AsyncPostBackTrigger ControlID=
"IntervalTimer"
EventName=
"Tick"
/>
117.
118.
</Triggers>
119.
120.
<ContentTemplate>
121.
122.
Time when Only Repeater data will Referesh : <asp:Literal ID=
"litrptRefresh"
runat=
"server"
Text=
"<b>repeater not refreshed yet.</b>"
></asp:Literal><br />(Repeater Will Referesh after Every 15 Second)
123.
124.
<br />
125.
126.
127.
128.
<table border=
"1px"
>
129.
130.
<tbody>
131.
<asp:Repeater id=
"myRepeater"
runat=
"server"
>
132.
<HeaderTemplate>
133.
<table border=
"1"
>
134.
<tr>
135.
<th>ชื่อโรงพยาบาล</th>
136.
<th>กรุ๊ปโลหิต</th>
137.
<th>ปริมาณโลหิต(ยูนิต/คน)</th>
138.
<th>ติดต่อ</th>
139.
140.
</tr>
141.
</HeaderTemplate>
142.
<ItemTemplate>
143.
<tr>
144.
<td align=
"left"
><asp:Label id=
"lblHospital"
runat=
"server"
></asp:Label></td>
145.
<td align=
"center"
><asp:Label id=
"lblBloodGroup"
runat=
"server"
></asp:Label></td>
146.
<td align=
"center"
><asp:Label id=
"lblQuantity"
runat=
"server"
></asp:Label></td>
147.
<td align=
"right"
><asp:LinkButton id=
"lnkDelete"
CommandName=
"Click"
runat=
"server"
>Click!</asp:LinkButton></td>
148.
149.
</ItemTemplate>
150.
</asp:Repeater>
151.
152.
</tbody>
153.
154.
</table>
155.
156.
</ContentTemplate>
157.
158.
</asp:UpdatePanel>
159.
160.
</form>
161.
</body>
162.
</html>