zoukankan      html  css  js  c++  java
  • 循环遍历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>
  • 相关阅读:
    Echarts
    递归
    svg(二)---半瓶子晃荡
    svg(一)
    angular --- s3core移动端项目(三)
    angular --- s3core移动端项目(二)
    angular --- s3core移动端项目
    当后台获取内容有标签时如何过滤---angular
    匿名函数的作用域
    Mybatis从浅入深(IDEA版通俗易懂)
  • 原文地址:https://www.cnblogs.com/yangwujun/p/3342762.html
Copyright © 2011-2022 走看看