ASP.NET 邮箱效果

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// carcs 的摘要说明
/// </summary>
public class carcs
{
    public carcs()
    {
    }
    public int Ids { get; set; }
    public string Code { get; set; }
    public string Name { get; set; }
    public string Brand { get; set; }
    public DateTime Time { get; set; }
    public decimal Oil { get; set; }
    public int Powers { get; set; }
    public int Exhaust { get; set; }
    public decimal Price { get; set; }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using System.Data.SqlClient;
public class CarData
{
    SqlConnection conn = null;
    SqlCommand cmd = null;
    public CarData()
    {
        conn = new SqlConnection("server=.;database=mydb;user=sa;pwd=123");
        cmd = conn.CreateCommand();
    }
    /// <summary>
    /// 删除效果
    /// </summary>
    /// <param name="code"></param>
    public void Delete(string code)
    {
        cmd.CommandText = "delete from car where code=@c";
        cmd.Parameters.Clear();
        cmd.Parameters.Add("@c", code);
        conn.Open();
        cmd.ExecuteNonQuery();//链接执行,并返回受影响的行数
        conn.Close();
    }
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default1.aspx.cs" Inherits="Default1" %>

<!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 type="text/css" >
        table {
            width:100%;
            background-color:navy;
            text-align :center;
            font-family:微软雅黑;
        }
        #tr1 {
            color:white;
        }
        .tr2 {
          background-color:#e0e0e0;
        }
    </style>
    <script type ="text/javascript">
        window.onload = function () {
            var oCkall = document.getElementById('ckall');
            oCkall.onclick = function () {
                var oCks = document.getElementsByClassName('ck');
                for (var i = 0; i < oCks.length ; i++) {
                    oCks[i].checked = this.checked;
                }
            };//全按钮的点击事件
            var oCkss = document.getElementsByClassName('ck');
            for (var i = 0; i < oCkss.length; i++)
            {
                oCkss[i].onclick = function ()
                {
                    //1.想要判断所有的CK是否被选中了
                    var Ckall = document.getElementById('ckall');
                    var ckss = document.getElementsByClassName('ck');
                    var count = 0;
                    for (var j = 0; j < Ckss.length; j++)
                    {
                        if (ckss[j].checked)
                        {
                            count++;
                        }
                    }
                    //2.如果都被选中了,那么全选要打钩
                    if (count == Ckss.length) {
                        Ckall.checked = true;
                    }
                    else {
                        Ckall.checked = false;
                    }
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:Button ID="Button1" runat="server" Text="删除" />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:Repeater ID="Repeater1" runat="server">
            <HeaderTemplate>
                <table>
                    <tr id="tr1">
                   <td width="50px">全选<input type="checkbox" id="ckall" /></td>
                        <td>ID</td>
                        <td>编号</td>
                       <td>名称</td>
                        <td>系别</td>
                        <td>油耗</td>
                        <td>马力</td>
                        <td>排量</td>
                        <td>价格</td>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr class="tr2">
                    <td>
                        <input type="checkbox"  class="ck" name="aa" value="<%#Eval("Code")%>" />
                    </td>
                    <td><%#Eval("Ids") %>></td>
                    <td><%#Eval("Code") %>></td>
                    <td><%#Eval("Name") %>></td>
                    <td><%#Eval("Brand") %>></td>
                    <td><%#Eval("Oil") %>></td>
                    <td><%#Eval("Powers") %>></td>
                    <td><%#Eval("Exhaust") %>></td>
                    <td><%#Eval("price") %>></td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </form>
</body>
</html>

 

posted @ 2016-07-27 15:03  一人饮酒醉(SeVen❤)  阅读(144)  评论(0编辑  收藏  举报