zoukankan      html  css  js  c++  java
  • Repeater 列表绑定数据源显示以及增删改查

    主界面aspx里的代码,很重要哦

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
        <style>
            .tr1 {
                background-color:#f00;
                text-align:center;
            }
      .tr2
            {
          text-align:center;
            }
    
        </style>
    </head>
    <body>
        <p>
            <br />
        </p>
        <form id="form1" runat="server">
        <div>
        
            <asp:Repeater ID="Repeater1" runat="server">
    

    <HeaderTemplate> <center> <table width="70%" border="1"><tr class="tr1"><td>编号</td><td>名称</td><td>价格</td><td>操作</td></tr> </HeaderTemplate> <ItemTemplate> <tr bgcolor="#FFFFCC" class="tr2"><td><%#Eval("Code") %></td><td><%#Eval("Name") %></td><td><%#Eval("Price") %></td><td><a href="Update.aspx?code=<%#Eval("Code") %>">修改</a><a href="Delete.aspx?code=<%#Eval("Code") %>"> 删除</a></td></tr> </ItemTemplate> <AlternatingItemTemplate> <tr class="tr2"><td><%#Eval("Code") %></td><td><%#Eval("Name") %></td><td><%#Eval("Price") %></td><td><a href="Update.aspx?code=<%#Eval("Code") %>">修改</a><a href="Delete.aspx?code=<%#Eval("Code") %>"> 删除</a></td></tr> </AlternatingItemTemplate> <FooterTemplate> </table></center> </FooterTemplate> </asp:Repeater> <a href="Insert.aspx"> 添加</a> </div> </form> </body> </html>


    aspx里的后台代码

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
    
            DataClassesDataContext _Context = new DataClassesDataContext();
            //给Repeater绑定数据源
            Repeater1.DataSource = _Context.Car.ToList();
            Repeater1.DataBind();
        }
    }
  • 相关阅读:
    django基础之ORM基础知识
    Centos7 搭建sonarQube
    centos7安装部署SVN
    centos7.5 SVN 搭建
    centos 7 部署 zookeeper
    centos7 发送邮件
    Centos7安装配置Gitlab-CE
    openldap 双主模式部署
    K8s一键安装
    ELK实战部署
  • 原文地址:https://www.cnblogs.com/275147378abc/p/4663878.html
Copyright © 2011-2022 走看看