循环遍历DataTable绑定到Table
VoteList2.cs:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Party.Ui; using SubSonic; using System.Data; public partial class V2VOTE_VoteList2 : System.Web.UI.Page { public DataTable B; protected override void OnInit(EventArgs e) { base.OnInit(e); } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindView(); } } private void BindView() { Select sel = new Select("ID", "Name"); sel.From("Vote").Where("isclosed").IsEqualTo(false); B = sel.ExecuteDataSet().Tables[0]; } }
VoteList2.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="VoteList2.aspx.cs" Inherits="V2VOTE_VoteList2" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div style="margin: 0px 0px 0px 0px"> <table cellpadding="0" cellspacing="0"> <% int Count = B.Rows.Count; for (int i = 0; i < Count; i++) { %> <tr class="odd" > <td><a style="text-decoration: none;" href='Vote.aspx?id=<%=B.Rows[i]["id"] %>'> <%=B.Rows[i][1].ToString() %> </a></td> </tr> <% } %> </table> </div> </form> </body> </html>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· AI Agent开发,如何调用三方的API Function,是通过提示词来发起调用的吗