虎克的博客

Enthusiasm Biogeography-Biodiversity Informatics-Data Sciences

DataList控件删除选中的记录

| Comments

2009-10-18_012535

Default.aspx页面代码

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "–//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    <asp:DataList ID="DataList1" runat="server" DataKeyField="CustomerID" RepeatColumns="3"
        RepeatDirection="Horizontal" DataSourceID="SqlDataSource1" CellPadding="4" 

ForeColor="#333333" OnEditCommand="DataList1_EditCommand" OnCancelCommand="DataList1_CancelCommand"

    </span><span style="color: red">OnDeleteCommand</span><span style="color: blue">=&quot;DataList1_DeleteCommand&quot;&gt;
    &lt;</span><span style="color: #a31515">FooterStyle </span><span style="color: red">BackColor</span><span style="color: blue">=&quot;#507CD1&quot; </span><span style="color: red">Font-Bold</span><span style="color: blue">=&quot;True&quot; </span><span style="color: red">ForeColor</span><span style="color: blue">=&quot;White&quot; /&gt;
    &lt;</span><span style="color: #a31515">AlternatingItemStyle </span><span style="color: red">BackColor</span><span style="color: blue">=&quot;White&quot; /&gt;
    &lt;</span><span style="color: #a31515">ItemStyle </span><span style="color: red">BackColor</span><span style="color: blue">=&quot;#EFF3FB&quot; /&gt;
    &lt;</span><span style="color: #a31515">SelectedItemStyle </span><span style="color: red">BackColor</span><span style="color: blue">=&quot;#D1DDF1&quot; </span><span style="color: red">Font-Bold</span><span style="color: blue">=&quot;True&quot; </span><span style="color: red">ForeColor</span><span style="color: blue">=&quot;#333333&quot; /&gt;
    &lt;</span><span style="color: #a31515">HeaderStyle </span><span style="color: red">BackColor</span><span style="color: blue">=&quot;#FF3399&quot; </span><span style="color: red">Font-Bold</span><span style="color: blue">=&quot;True&quot; </span><span style="color: red">ForeColor</span><span style="color: blue">=&quot;#FF99CC&quot; </span><span style="color: red">Font-Italic</span><span style="color: blue">=&quot;False&quot;
        </span><span style="color: red">Font-Overline</span><span style="color: blue">=&quot;False&quot; </span><span style="color: red">Font-Strikeout</span><span style="color: blue">=&quot;False&quot; </span><span style="color: red">Font-Underline</span><span style="color: blue">=&quot;False&quot; /&gt;
    &lt;</span><span style="color: #a31515">ItemTemplate</span><span style="color: blue">&gt;
        </span>CustomerID:
        <span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Label </span><span style="color: red">ID</span><span style="color: blue">=&quot;CustomerIDLabel&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">Text</span><span style="color: blue">='</span><span style="background: #ffee62">&lt;%</span># Eval(&quot;CustomerID&quot;) <span style="background: #ffee62">%&gt;</span><span style="color: blue">' /&gt;
        &lt;</span><span style="color: #a31515">br </span><span style="color: blue">/&gt;
        </span>CompanyName:
        <span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Label </span><span style="color: red">ID</span><span style="color: blue">=&quot;CompanyNameLabel&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">Text</span><span style="color: blue">='</span><span style="background: #ffee62">&lt;%</span># Eval(&quot;CompanyName&quot;) <span style="background: #ffee62">%&gt;</span><span style="color: blue">' /&gt;
        &lt;</span><span style="color: #a31515">br </span><span style="color: blue">/&gt;
        </span>ContactName:
        <span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Label </span><span style="color: red">ID</span><span style="color: blue">=&quot;ContactNameLabel&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">Text</span><span style="color: blue">='</span><span style="background: #ffee62">&lt;%</span># Eval(&quot;ContactName&quot;) <span style="background: #ffee62">%&gt;</span><span style="color: blue">' /&gt;
        &lt;</span><span style="color: #a31515">br </span><span style="color: blue">/&gt;
        </span>ContactTitle:
        <span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Label </span><span style="color: red">ID</span><span style="color: blue">=&quot;ContactTitleLabel&quot; </span><span style="color: red">runat<<p class='post-footer'>
   original link:
   <a href='http://Apiaceae.github.io/blog/2009/10/18/DataList%E6%8E%A7%E4%BB%B6%E5%88%A0%E9%99%A4%E9%80%89%E4%B8%AD%E7%9A%84%E8%AE%B0%E5%BD%95/'>http://Apiaceae.github.io/blog/2009/10/18/DataList%E6%8E%A7%E4%BB%B6%E5%88%A0%E9%99%A4%E9%80%89%E4%B8%AD%E7%9A%84%E8%AE%B0%E5%BD%95/</a><br/>
   &nbsp;written by <a href='http://Apiaceae.github.io'>Hooker</a>
   &nbsp;posted at <a href='http://Apiaceae.github.io'>http://Apiaceae.github.io</a>
   </p>

Comments