Repeater 實現增刪改功能
阿新 • • 發佈:2019-01-22
<asp:Repeater ID="rptsubject" runat="server" OnItemDataBound="rptsubject_ItemDataBound" OnItemCommand="rptsubject_ItemCommand" >
<HeaderTemplate>
<table id="tableinfo" border="1px" style="border-collapse: collapse;" bordercolor="#6898be" cellpadding="2px" cellspacing="0">
<tr style="height:22px; background-color:#bee4fb; text-align:center;">
<th style="width:65px; font-weight:normal;">序號</th>
<th style="width:300px; font-weight:normal;">科目名稱</th>
<th style="width:80px; font-weight:normal;">修改</th>
<th style="width:80px; font-weight:normal;">刪除</th>
</tr>
<tbody id="trId">
</HeaderTemplate>
<ItemTemplate>
<asp:Panel ID="plItem" runat="server">
<tr style="height:17px; background-color:White; text-align:center;">
<td><asp:Label ID="lblNum" runat="server" Text="Label"></asp:Label></td>
<td><%# Eval("SubjectName")%></td>
<td><asp:ImageButton ID="lbtEdit" ImageUrl="../images/bm_update.gif" CommandName="Edit" CommandArgument='<%# Eval("SubjectId") %>' runat="server" /></td>
<td><asp:ImageButton ID="lbtDelete" ImageUrl="../images/bm_delete.gif" CommandName="Delete" CommandArgument='<%# Eval("SubjectId") %>' runat="server" /></td>
</tr>
</asp:Panel>
<asp:Panel ID="plEdit" runat="server">
<tr style="height:17px; background-color:White; text-align:center;">
<td style="background-color:#fff;"><asp:Label ID="lblNum2" runat="server" Text="Label"></asp:Label></td>
<td style="background-color:#fff;"><asp:TextBox ID="txtA" MaxLength="20" Text='<%# Eval("SubjectName")%>' runat="server" Width="50px"></asp:TextBox></td>
<td style="background-color:#fff;"><asp:LinkButton runat="server" ID="lbtUpdate" CommandArgument='<%# Eval("SubjectId") %>' CommandName="Update" Text="更新"></asp:LinkButton>
<asp:LinkButton runat="server" ID="lbtCancel" CommandArgument='<%# Eval("SubjectId") %>' CommandName="Cancel" Text="取消"></asp:LinkButton></td>
<td style="background-color:#fff;"></td>
</tr>
</asp:Panel>
</ItemTemplate>
<AlternatingItemTemplate>
<asp:Panel ID="plItem" runat="server">
<tr style="height:17px; text-align:center;">
<td><asp:Label ID="lblNum" runat="server" Text="Label"></asp:Label></td>
<td><%# Eval("SubjectName")%></td>
<td><asp:ImageButton ID="lbtEdit" ImageUrl="../images/bm_update.gif" CommandName="Edit" CommandArgument='<%# Eval("SubjectId") %>' runat="server" /></td>
<td><asp:ImageButton ID="lbtDelete" ImageUrl="../images/bm_delete.gif" CommandName="Delete" CommandArgument='<%# Eval("SubjectId") %>' runat="server" /></td>
</tr>
</asp:Panel>
<asp:Panel ID="plEdit" runat="server">
<tr style="height:17px; background-color:White; text-align:center;">
<td style="background-color:#fff;"><asp:Label ID="lblNum2" runat="server" Text="Label"></asp:Label></td>
<td style="background-color:#fff;"><asp:TextBox ID="txtA" MaxLength="20" Text='<%# Eval("SubjectName")%>' runat="server" Width="50px"></asp:TextBox></td>
<td style="background-color:#fff;"><asp:LinkButton runat="server" ID="lbtUpdate" CommandArgument='<%# Eval("SubjectId") %>' CommandName="Update" Text="更新"></asp:LinkButton>
<asp:LinkButton runat="server" ID="lbtCancel" CommandArgument='<%# Eval("SubjectId") %>' CommandName="Cancel" Text="取消"></asp:LinkButton></td>
<td style="background-color:#fff;"></td>
</tr>
</asp:Panel>
</AlternatingItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
<HeaderTemplate>
<table id="tableinfo" border="1px" style="border-collapse: collapse;" bordercolor="#6898be" cellpadding="2px" cellspacing="0">
<tr style="height:22px; background-color:#bee4fb; text-align:center;">
<th style="width:65px; font-weight:normal;">序號</th>
<th style="width:300px; font-weight:normal;">科目名稱</th>
<th style="width:80px; font-weight:normal;">修改</th>
<th style="width:80px; font-weight:normal;">刪除</th>
</tr>
<tbody id="trId">
</HeaderTemplate>
<ItemTemplate>
<asp:Panel ID="plItem" runat="server">
<tr style="height:17px; background-color:White; text-align:center;">
<td><asp:Label ID="lblNum" runat="server" Text="Label"></asp:Label></td>
<td><%# Eval("SubjectName")%></td>
<td><asp:ImageButton ID="lbtEdit" ImageUrl="../images/bm_update.gif" CommandName="Edit" CommandArgument='<%# Eval("SubjectId") %>' runat="server" /></td>
<td><asp:ImageButton ID="lbtDelete" ImageUrl="../images/bm_delete.gif" CommandName="Delete" CommandArgument='<%# Eval("SubjectId") %>' runat="server" /></td>
</tr>
</asp:Panel>
<asp:Panel ID="plEdit" runat="server">
<tr style="height:17px; background-color:White; text-align:center;">
<td style="background-color:#fff;"><asp:Label ID="lblNum2" runat="server" Text="Label"></asp:Label></td>
<td style="background-color:#fff;"><asp:TextBox ID="txtA" MaxLength="20" Text='<%# Eval("SubjectName")%>' runat="server" Width="50px"></asp:TextBox></td>
<td style="background-color:#fff;"><asp:LinkButton runat="server" ID="lbtUpdate" CommandArgument='<%# Eval("SubjectId") %>' CommandName="Update" Text="更新"></asp:LinkButton>
<asp:LinkButton runat="server" ID="lbtCancel" CommandArgument='<%# Eval("SubjectId") %>' CommandName="Cancel" Text="取消"></asp:LinkButton></td>
<td style="background-color:#fff;"></td>
</tr>
</asp:Panel>
</ItemTemplate>
<AlternatingItemTemplate>
<asp:Panel ID="plItem" runat="server">
<tr style="height:17px; text-align:center;">
<td><asp:Label ID="lblNum" runat="server" Text="Label"></asp:Label></td>
<td><%# Eval("SubjectName")%></td>
<td><asp:ImageButton ID="lbtEdit" ImageUrl="../images/bm_update.gif" CommandName="Edit" CommandArgument='<%# Eval("SubjectId") %>' runat="server" /></td>
<td><asp:ImageButton ID="lbtDelete" ImageUrl="../images/bm_delete.gif" CommandName="Delete" CommandArgument='<%# Eval("SubjectId") %>' runat="server" /></td>
</tr>
</asp:Panel>
<asp:Panel ID="plEdit" runat="server">
<tr style="height:17px; background-color:White; text-align:center;">
<td style="background-color:#fff;"><asp:Label ID="lblNum2" runat="server" Text="Label"></asp:Label></td>
<td style="background-color:#fff;"><asp:TextBox ID="txtA" MaxLength="20" Text='<%# Eval("SubjectName")%>' runat="server" Width="50px"></asp:TextBox></td>
<td style="background-color:#fff;"><asp:LinkButton runat="server" ID="lbtUpdate" CommandArgument='<%# Eval("SubjectId") %>' CommandName="Update" Text="更新"></asp:LinkButton>
<asp:LinkButton runat="server" ID="lbtCancel" CommandArgument='<%# Eval("SubjectId") %>' CommandName="Cancel" Text="取消"></asp:LinkButton></td>
<td style="background-color:#fff;"></td>
</tr>
</asp:Panel>
</AlternatingItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>