CODE
<!--#INCLUDE file="db.aspx"-->
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8" %>
<html>
<head>
<title>View Uploaded Videos</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="780" border="0" align="center" cellpadding="10" cellspacing="0">
<%
Dim Page As String = Request("page")
If Page <> "" Then
Page = Convert.ToInt32(Page)
Else
Page = 1
End If
Dim Dc As OleDbConnection = OpenDB()
'Get the total number of uploaded videos
Dim Cmd As OleDbCommand = new OleDbCommand("SELECT COUNT(*) FROM VIDEOS", Dc)
Dim Reader As OleDbDataReader = Cmd.ExecuteReader()
Reader.Read()
Dim TotalVideos As Int32 = Reader.GetInt32(0)
Reader.Close()
'Get the rows of the current page
Dim Sql As String = "SELECT * FROM VIDEOS ORDER BY UPLOADTIME DESC"
Dim Da As OleDbDataAdapter = new OleDbDataAdapter(Sql, Dc)
Dim Ds As DataSet = New DataSet()
Da.Fill(Ds, PageSize * (Page - 1), PageSize, "VIDEOS")
Dim Dt As DataTable = Ds.Tables(0)
%>
<tr>
<td colspan="2" align="left"><p class="large">There are <%=TotalVideos%> videos in total</p></td>
</tr>
<tr>
<td height="30" colspan="2" align="right"><p><a href="upload.aspx">Upload my video now >><br>
</a> </p>
<hr align="left" size="1" noshade></td>
</tr>
<%
For I As Integer = 0 To Dt.Rows.Count - 1
Dim Dr As DataRow = Dt.Rows(i)
Dim ID As String = Dr("ID")
Dim ImageFile As String = Dr("IMAGEFILE")
Dim Author As String = Dr("AUTHOR")
If (Len(Author) = 0) Then Author = "Anonymous"
Dim Title As String = Dr("TITLE")
If (Len(Title) = 0) Then Title = "Untitled"
Dim Duration As Integer = Dr("DURATION")
Dim UploadTime As Date = Dr("UPLOADTIME")
Dim Views As Integer = Dr("VIEWS")
%>
<tr>
<td width="160" height="120" rowspan="2" align="center" valign="middle"><a href="play.aspx?id=<%=ID%>" ><img src="<%="files/" + ImageFile%>" border="0"></a></td>
<td align="left" valign="top" class="small"><a href="play.aspx?id=<%=ID%>" class="large"><strong><%=Server.HtmlEncode(Title)%></strong></a></td>
</tr>
<tr>
<td align="left" valign="top" class="small"><span class="gray"> Duration: <%=TimeToString(Duration)%><br>
Uploaded by: <%=Server.HtmlEncode(Author)%> <br>
Upload date: <%=FormatDateTime(UploadTime, 2) + " " + FormatDateTime(UploadTime, 3)%><br>
Views: <%=Views%> </span> </td>
</tr>
<tr>
<td height="1" colspan="2" align="left" valign="middle"><hr align="left" size="1" noshade></td>
</tr>
<%
Next
%>
<tr>
<td height="40" colspan="2" align="center">See more:
<%
PrintPages(TotalVideos, Page)
%>
</td>
</tr>
<tr>
<td height="40" colspan="2"><a href="upload.aspx">Upload my video now >> <br>
</td>
</tr>
</table>
</body>
</html>
<script language="VB" runat="server">
' Convert total seconds to HH:MM:SS format
Function TimeToString(Duration As Integer) As String
Dim h, m, s
h = Int(Duration / 3600)
m = Int((Duration Mod 3600) / 60)
s = Int((Duration Mod 60) Mod 3600)
TimeToString = FormatTimeElement(h) + ":" + FormatTimeElement(m) + ":" + FormatTimeElement(s)
End Function
Function FormatTimeElement(Element As String) As String
FormatTimeElement = CStr(Element)
If (Element < 10) Then
FormatTimeElement = "0" + FormatTimeElement
End If
End Function
Sub PrintPages(TotalVideos As Integer, CurrentPage As Integer)
Dim TotalPages As Integer = TotalVideos \ PageSize 'Do not use '/' operator because we want to return Integer (not rounded)
If (TotalVideos Mod PageSize > 0) Then TotalPages += 1
Dim I As Integer
For I = 1 To TotalPages
If (I <> CurrentPage) Then
Response.Write("<a href=""list.aspx?page=" & I & """>" & I & "</a>")
Else
Response.Write("<b>" & I & "</b>")
End If
If I < TotalPages Then
Response.Write(" ")
End If
Next
End Sub
</script>
im having problems figuring how to add gride view ! into this page, right now it only shows view list format for thumbnails loaded from mdb.
this code is part of a tiny mini youtube style video sharing application on asp.net , i need help to figure this.