• 20151217:Web之Repeater使用:主页面


    主页面前台HTML代码:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="1217.aspx.cs" Inherits="_1217" %>
    
    <!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>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
            <asp:Repeater ID="Repeater1" runat="server">
                <HeaderTemplate>
                    <table width="800" border="0" cellspacing="1" cellpadding="1" bgcolor="#6600FF">
                      <tr>
                        <td width="120" height="30" align="center" valign="middle" bgcolor="#FFFFFF">代号</td>
                        <td width="120" align="center" valign="middle" bgcolor="#FFFFFF">名称</td>
                        <td width="120" align="center" valign="middle" bgcolor="#FFFFFF">价格</td>
                        <td width="120" align="center" valign="middle" bgcolor="#FFFFFF" >产地</td>
                        <td width="100" align="center" valign="middle" bgcolor="#FFFFFF">库存</td>
                        <td width="100" align="center" valign="middle" bgcolor="#FFFFFF">操作</td>
                       </tr>
                </HeaderTemplate>
                <ItemTemplate>
    
                    <tr>
                        <td width="120" height="30" align="center" valign="middle" bgcolor="#FFFFFF"><%#Eval("Ids") %></td>
                        <td width="120" align="center" valign="middle" bgcolor="#FFFFFF"><%#Eval("Name") %></td>
                        <td width="120" align="center" valign="middle" bgcolor="#FFFFFF"><%#Eval("Price") %></td>
                        <td width="120" align="center" valign="middle" bgcolor="#FFFFFF" ><%#Eval("Source") %></td>
                        <td width="100" align="center" valign="middle" bgcolor="#FFFFFF"><%#Eval("Numbers") %></td>
                        <td width="100" align="center" valign="middle" bgcolor="#FFFFFF"><a href="Delete.aspx?ids=<%#Eval("ids") %>">删除</a>&nbsp;<a href="Update.aspx?ids=<%#Eval("ids") %>">修改</a></td>
                       </tr>
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
        
        </div>
            <br />
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="增加" />
        </form>
    </body>
    </html>

    后台C#代码:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class _1217 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            TestDataContext context = new TestDataContext();
            //绑定数据
            Repeater1.DataSource = context.Fruit;
            Repeater1.DataBind();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            //增加跳转页面
            Response.Redirect("Insert.aspx");
        }
    }

  • 相关阅读:
    leetcode回溯总结
    排序算法详解
    Java核心基础知识泛型
    leetcode贪心算法
    Linux虚拟机配置及安装Redis
    HJ6质数因子
    冒泡排序(升序)
    动态规划 背包问题
    配置mycatschema.xml
    HJ106字符逆序
  • 原文地址:https://www.cnblogs.com/mn-b/p/5068839.html
Copyright © 2020-2023  润新知