您的位置:首页 > 其它

Repeater嵌套,增删改查综合运用

2009-05-07 16:02 225 查看
using System;

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page

<!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>

<asp:Repeater ID="rptClass" runat="server" OnItemCommand="rptClass_ItemCommand" OnItemDataBound="rptClass_ItemDataBound">

<HeaderTemplate>

<table>

<tr style="background-color:yellow">

<td>

添加类别:

<asp:TextBox ID="txtClassName" runat="server">

</asp:TextBox>

<asp:Button ID="btnAddClass" runat="server" CommandName="AddClass" Text="添加" />

</td>

</tr>

</HeaderTemplate>

<ItemTemplate>

<tr style="background-color:#CCCCCC">

<td>

<asp:Button ID="btnDelClass" CommandArgument='<%# Eval("id") %>' CommandName="DelClass" runat="server" Text="删除类别" />

<asp:TextBox ID="txtClassName" runat="server" Text='<%# Eval("className") %>'>

</asp:TextBox>

<asp:Button ID="btnUpdateClass" CommandArgument='<%# Eval("id") %>' CommandName="UpdateClass" runat="server" Text="修改类别" />

</td>

</tr>

<tr>

<td>

添加模块:

<asp:TextBox ID="txtModuleName" runat="server">

</asp:TextBox>

<asp:Button ID="btnAddModule" runat="server" CommandName="AddModule" CommandArgument='<%# Eval("id") %>' Text="添加" />

</td>

</tr>

<tr>

<td>

<asp:Repeater ID="rptModule" runat="server"

OnItemCommand='rptModule_ItemCommand'>

<ItemTemplate>

<tr>

<td>

    -----------------

<asp:Button ID="btnDeleteModule" CommandArgument='<%# Eval("id") %>' CommandName="DelModule" runat="server" Text="删除模块" />

<asp:TextBox ID="txtModuleName" Text='<%# Eval("moduleName") %>' runat="server"></asp:TextBox>

<asp:Button ID="btnUpdateModule" CommandArgument='<%# Eval("id") %>' CommandName="UpdateModule" runat="server" Text="修改模块" />

</td>

</tr>

</ItemTemplate>

</asp:Repeater>

</td>

</tr>

</ItemTemplate>

<FooterTemplate>

</table>

</FooterTemplate>

</asp:Repeater>

</div>

</form>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: