代码如下:<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %><!-- 声明一个 DataList 控件,作为"购书篮" -->
<asp:DataList id="ShoppingCart"   HorizontalAlign="center"  RepeatColumns="1" 
     OnItemCommand="Cart_Remove" runat="server">
     <template Name="HeaderTemplate">
    <center><font color="linen" Size=+2><b>购书篮</b></font></center>
    <hr width="260" color="MidnightBlue">
     </template>
     <!--定义项目模板-->
     <template name="ItemTemplate">
  <table CellSpacing="2" Align="Center" style="color:Gold" width="260">
  <tr>
     <td width="50%" style="color:Lavender">书名:
        <asp:Label id="lblTitle" ForeColor="Gold" runat="server"
   text='<% # DataBinder.Eval(Container.DataItem,"书名") %>'/>
            </td>
    <td width="38%" style="color:Lavender">单价:
        <asp:Label id="lblPrice" ForeColor="Gold" runat="server"
   text='<% # DataBinder.Eval(Container.DataItem,"单价") %>'/>
            </td>
    <td>
       <asp:LinkButton id="lbtnEdit" runat="server"
           Text="移出" Commandname="Remove" />
            </td>
        </tr>
<tr>
   <td width="50%" style="color:Lavender">购买数量:
    <asp:TextBox id="txtQuantity" width="30" height="18" runat="server"
        text='<% # DataBinder.Eval(Container.DataItem,"数量") %>'/>
          </td>
  <td width="38%" style="color:Lavender">总价:
   <asp:label id="lblItemTotal" ForeColor="Gold" runat="server" text=
       '<% # DataBinder.Eval(Container.DataItem,"总价","{0:c}") %>'/>
          </td>
        </tr>
        </table>
    </template>
    <!--定义分隔符模板-->
    <template name="SeparatorTemplate">
    <hr>
    </template>
    <!--定义脚注模板-->
    <template name="FooterTemplate">
   <hr width="260" color="MidnightBlue">
    </template>
</asp:DataList><asp:Panel id="CheckoutPanel" ruanat="server" width="260"
    HorizontalAlign="Center" BackColor="Moccasin">
    <br><b>总金额:</b>
    <asp:label id="lblSubTotal" ForeColor="DarkRed" runat="server" />
    <p><asp:LinkButton id="btnRecalculate" runat="server"
       Text='重新汇总' OnClick="btnRecalculate_Click"/>&nbsp;&nbsp;
   <asp:LinkButton id="btnCheckOut" runat="server"
       Text='结账' OnClick="btnCheckOut_Click"/>&nbsp;&nbsp;
   <asp:LinkButton id="btnClearCart" runat="server"
       Text='清空购书篮' OnClick="btnClearCart_Click"/>
   <p><asp:label id="lblCheckOut" FireColor="DarkRed" runat="server"/>
</asp:Panel>系统报:Parser Error Message: Type 'System.Web.UI.WebControls.DataList' does not have a property named 'template'.

解决方案 »

  1.   

    楼主最好用 VS.Net来开发 这些代码都可以给你生成的。
      

  2.   

    <asp:DataList id="DataList1" style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP: 232px"
    runat="server">
    <HeaderTemplate>
    123
    </HeaderTemplate>
    <SelectedItemTemplate>
    asd
    </SelectedItemTemplate>
    <FooterTemplate>
    123
    </FooterTemplate>
    <ItemTemplate>
    asd
    </ItemTemplate>
    <SeparatorTemplate>
    123
    </SeparatorTemplate>
    <AlternatingItemTemplate>
    asd
    </AlternatingItemTemplate>
    <EditItemTemplate>
    asd
    </EditItemTemplate>
    </asp:DataList>
      

  3.   

    没有template这个属性,有HeaderTemplate,ItemTemplate,SelectedItemTemplate...等等