Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
pro_id = Request("pid")
type_id_sub = Request("xid")
Dim Data1 As New PTGData
Dim DT As Data.DataTable = Data1.GetdataTable("select * From product where pro_id = '" & pro_id & "'")
RepeaterDetail.DataSource = DT
RepeaterDetail.DataBind()
End Sub
Code หน้า Test.aspx
<asp:Repeater ID="RepeaterDetail" runat="server">
<ItemTemplate>
<div>
<%
Dim manual As String
manual = Eval("pro_manual")
If manual = 1 Then
%>
<A HREF="Manual/<%#Eval("type_id_sub") %>.pdf" target = "_blank">
<b><asp:Label ID="Label1" runat="server" Text="Download คู่มือการติดตั้ง "></asp:Label></b><br/>
</A>
<%
End If
%>
</div>
</ItemTemplate>
</asp:Repeater>
Protected Sub myRepeater_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs) Handles myRepeater.ItemDataBound
'*** CustomerID ***'
Dim lblCustomerID As Label = CType(e.Item.FindControl("lblCustomerID"),Label)
IF Not IsNothing(lblCustomerID) Then
lblCustomerID.Text = e.Item.DataItem("CustomerID")
End IF
'*** Name ***'
Dim lblName As Label = CType(e.Item.FindControl("lblName"),Label)
IF Not IsNothing(lblName) Then
lblName.Text = e.Item.DataItem("Name")
End IF
End Sub
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="testif.aspx.vb" Inherits="testif" %>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OleDb"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Dim objConn As OleDbConnection
Dim objCmd As OleDbCommand
Sub Page_Load(sender As Object, e As EventArgs)
Dim strConnString As String
strConnString = "Server=webserver;uid=test;pwd=test1;database=DBPTGCatalog;"
objConn = New OleDbConnection(strConnString)
objConn.Open()
BindData()
End Sub
Sub BindData()
Dim strSQL As String
strSQL = "SELECT * FROM product where type_id = '10'"
Dim dtReader As OleDbDataReader
objCmd = New OleDbCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
'*** BindData to Repeater ***'
myRepeater.DataSource = dtReader
myRepeater.DataBind()
dtReader.Close()
dtReader = Nothing
End Sub
Sub Page_UnLoad()
objConn.Close()
objConn = Nothing
End Sub
Protected Sub myRepeater_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs) Handles myRepeater.ItemDataBound
'*** pro_id ***'
Dim lblpro_id As Label = CType(e.Item.FindControl("lblpro_id"), Label)
If Not IsNothing(lblpro_id) Then
lblpro_id.Text = e.Item.DataItem("pro_id")
End If
'*** pro_name ***'
Dim lblpro_name As Label = CType(e.Item.FindControl("lblpro_name"), Label)
If Not IsNothing(lblpro_name) Then
lblpro_name.Text = e.Item.DataItem("pro_name")
End If
'*** pro_color ***'
Dim lblpro_Color As Label = CType(e.Item.FindControl("lblpro_Color"), Label)
If Not IsNothing(lblpro_Color) Then
lblpro_Color.Text = e.Item.DataItem("pro_color")
End If
'*** pro_size ***'
Dim lblpro_Size As Label = CType(e.Item.FindControl("lblpro_Size"), Label)
If Not IsNothing(lblpro_Size) Then
lblpro_Size.Text = e.Item.DataItem("pro_size")
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="myRepeater" runat="server">
<HeaderTemplate>
<table border="1">
<tr>
<th>Pro ID</th>
<th>Pro Name</th>
<th>Pro Color</th>
<th>Pro size</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:Label id="lblpro_id" runat="server"></asp:Label></td>
<td><asp:Label id="lblpro_name" runat="server"></asp:Label></td>
<td><asp:Label id="lblpro_Color" runat="server"></asp:Label></td>
<td><asp:Label id="lblpro_Size" runat="server"></asp:Label></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr bgcolor="#e8e8e8">
<td><asp:Label id="lblpro_id" runat="server"></asp:Label></td>
<td><asp:Label id="lblpro_name" runat="server"></asp:Label></td>
<td><asp:Label id="lblpro_Color" runat="server"></asp:Label></td>
<td><asp:Label id="lblpro_Size" runat="server"></asp:Label></td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
<!--
<tr>
<th>Pro ID</th>
<th>Pro Name</th>
<th>Pro Color</th>
<th>Pro size</th>
</tr>
-->
</table>
</FooterTemplate>
</asp:Repeater>
</table>
</div>
</form>
</body>
</html>