asp.net--ListView中ItemTemplate设置与功能按钮
.aspx代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %> <!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> <style type="text/css"> .divItem{ padding:5px; } .divBtns{ width:130px; float:left;} .divInfo{ width:350px; padding:0px 10px 0px 10px; border-left:1px solid #dadada; border-right:1px solid #dadada; float:left;} .divInfo2{ width:200px; float:left;} .clr{ clear:both;} </style> </head> <body> <form id="form1" runat="server"> <div> <asp:listview ID="Listview1" runat="server" DataSourceID="AccessDataSource1" ItemPlaceholderID="itemHolder"> <LayoutTemplate> <div id="itemHolder" runat="server"> </div> </LayoutTemplate> <ItemTemplate> <div class="divItem"> <div class="divBtns"> <asp:Button ID="btn_edit" runat="server" Text="编辑" CommandName="edit"/><br /> <asp:Button ID="btn_delete" runat="server" Text="删除" CommandName="delete"/> </div> <div class="divInfo"> <h2><%#Eval("se_name") %></h2> <p><%#Eval("se_memo") %></p> </div> <div class="divInfo2"> <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%#Eval("se_enable") %>' Enabled="false" Text="有效性"/> <p>排序:<%#Eval("se_order") %></p> </div> <div class="clr"></div> </div> </ItemTemplate> </asp:listview> <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/mdb/EV.mdb" DeleteCommand="DELETE FROM [T_SERIES] WHERE [se_id] = ?" InsertCommand="INSERT INTO [T_SERIES] ([se_id], [se_name], [se_memo], [se_order], [se_enable], [se_delete]) VALUES (?, ?, ?, ?, ?, ?)" SelectCommand="SELECT * FROM [T_SERIES]" UpdateCommand="UPDATE [T_SERIES] SET [se_name] = ?, [se_memo] = ?, [se_order] = ?, [se_enable] = ?, [se_delete] = ? WHERE [se_id] = ?"> <DeleteParameters> <asp:Parameter Name="se_id" Type="Int32" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="se_id" Type="Int32" /> <asp:Parameter Name="se_name" Type="String" /> <asp:Parameter Name="se_memo" Type="String" /> <asp:Parameter Name="se_order" Type="Int32" /> <asp:Parameter Name="se_enable" Type="Boolean" /> <asp:Parameter Name="se_delete" Type="Boolean" /> </InsertParameters> <UpdateParameters> <asp:Parameter Name="se_name" Type="String" /> <asp:Parameter Name="se_memo" Type="String" /> <asp:Parameter Name="se_order" Type="Int32" /> <asp:Parameter Name="se_enable" Type="Boolean" /> <asp:Parameter Name="se_delete" Type="Boolean" /> <asp:Parameter Name="se_id" Type="Int32" /> </UpdateParameters> </asp:AccessDataSource> </div> </form> </body> </html>
效果如下:
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。