<%@ page language="VB" debug="true" %>
<%@import namespace="System.Data.SqlClient"%>
<%@import namespace="System.Data"%>
<html>
<head>
<title>Repeater控件的使用</title>
<script runat="server">
Dim Dt As New DataTable()
Dim Dv As DataView Sub Page_Load(Sender As Object,E As EventArgs)
If Not IsPostBack Then
Dim cnn As SqlConnection
Dim cmd As SqlCommand
Dim dap As SqlDataAdapter
Dim dst As DataSet
Dim dtb As DataTable
Dim drow As DataRow
cnn = New SqlConnection("server=tmd;uid=sa;pwd=sa;database=NorthWind;")
cnn.Open()
cmd = New SqlCommand("select * from Categories", cnn)
dap = New SqlDataAdapter(cmd)
dst = New DataSet
dap.Fill(dst, "Categories")
theRepeater.DataSource = dst.Tables("Categories")
theRepeater.databind()
End If
End Sub
</script>
</head>
<body>
<h2 align="center">Repeater控件的使用<hr></h2>
<form runat="server">
<Center>
<asp:Repeater id="theRepeater" Runat="Server">
<HeaderTemplate>
<Table width="80%" border="0">
<tr>
<th height="30" valign="top">CategoryID</th>
<th height="30" valign="top">CategoryName</th>
<th height="30" valign="top">Description</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td align="center"><%# Container.DataItem("CategoryID") %></td>
<td align="center"><%# Container.DataItem("CategoryName") %></td>
<td><%# Container.DataItem("Description") %></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
<td align="center" bgcolor="#ffcc00"><%# Container.DataItem("CategoryID") %></td>
<td align="center" bgcolor="#ffcc00"><%# Container.DataItem("CategoryName") %></td>
<td bgcolor="#ffcc00"><%# Container.DataItem("Description") %></td>
</tr>
</AlternatingItemTemplate>
<SeparatorTemplate>
<tr>
<td height="1" colspan="3"><hr></td>
</tr>
</SeparatorTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</Center>
</form>
</body>
<%@import namespace="System.Data.SqlClient"%>
<%@import namespace="System.Data"%>
<html>
<head>
<title>Repeater控件的使用</title>
<script runat="server">
Dim Dt As New DataTable()
Dim Dv As DataView Sub Page_Load(Sender As Object,E As EventArgs)
If Not IsPostBack Then
Dim cnn As SqlConnection
Dim cmd As SqlCommand
Dim dap As SqlDataAdapter
Dim dst As DataSet
Dim dtb As DataTable
Dim drow As DataRow
cnn = New SqlConnection("server=tmd;uid=sa;pwd=sa;database=NorthWind;")
cnn.Open()
cmd = New SqlCommand("select * from Categories", cnn)
dap = New SqlDataAdapter(cmd)
dst = New DataSet
dap.Fill(dst, "Categories")
theRepeater.DataSource = dst.Tables("Categories")
theRepeater.databind()
End If
End Sub
</script>
</head>
<body>
<h2 align="center">Repeater控件的使用<hr></h2>
<form runat="server">
<Center>
<asp:Repeater id="theRepeater" Runat="Server">
<HeaderTemplate>
<Table width="80%" border="0">
<tr>
<th height="30" valign="top">CategoryID</th>
<th height="30" valign="top">CategoryName</th>
<th height="30" valign="top">Description</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td align="center"><%# Container.DataItem("CategoryID") %></td>
<td align="center"><%# Container.DataItem("CategoryName") %></td>
<td><%# Container.DataItem("Description") %></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
<td align="center" bgcolor="#ffcc00"><%# Container.DataItem("CategoryID") %></td>
<td align="center" bgcolor="#ffcc00"><%# Container.DataItem("CategoryName") %></td>
<td bgcolor="#ffcc00"><%# Container.DataItem("Description") %></td>
</tr>
</AlternatingItemTemplate>
<SeparatorTemplate>
<tr>
<td height="1" colspan="3"><hr></td>
</tr>
</SeparatorTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</Center>
</form>
</body>
解决方案 »
- JQuery该怎么样学?
- 使用了 Microsoft Visual Studio 2005/8 Team System 是不是就不用再安装 Microsoft Visual Sourc
- 【向everyone提问】很想知道asp.net的一个关于生命周期的问题
- 找不到类型或命名空间名称“AspcnValidate”??菜鸟散分
- 请教大家,怎样将文件上传到几个不同的服务器上?
- 我装了Visual Web Developer 2005 Express Edition,但是却有一些问题要问下各位高手
- 如何在关闭页面时,自动转到另一个页面?
- 未能在 ControlParameter “XXX” 中找到控件 “XXX”
- 递归 树形结构
- 事件没有执行
- 两个窗口a.aspx和b.aspx,传值的问题????
- 请问我这个怎么没有循环??急~~
比如 "完成计划比率"列,就来自2个表"完成表""计划表".这样的话Repeater只能绑定一个数据源啊????