博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Repeater控件

Posted on 2009-03-21 16:53  Aimee  阅读(239)  评论(0)    收藏  举报

批量更新,批量删除
DIV《=============》Pannel(Fill全局)
客户端标记 服务器端控件

CSS

Repeater控件

<asp:Repeater ID="rptContent" runat="server"
                    onitemcommand="rptContent_ItemCommand"gt;
                    <ItemTemplate>
                        <div class="logtop"gt;
                            <div class="logtitle"gt;
                                <%#Eval("AccountClassName") %gt;
                                |
                                <%#Eval("AccountDate") %gt;
                            </div>
                        </div>
                        <div class="logmiddle"gt;
                            <div class="logtext"gt;
                                <%#Eval("AccountDescription") %gt;
                            </div>
                        </div>
                        <div class="logbottom"gt;
                            <div class="logmore"gt;
                            <asp:LinkButton ID="LinkButton1" CommandArgument='lt;%#Eval("AccountID")%gt;' CommandName="replyAuthor" runat="server"gt;回复作者lt;/asp:LinkButtongt;
                                 | <asp:LinkButton ID="LinkButton2" CommandArgument='lt;%#Eval("AccountID")%gt;' CommandName="deleteAuthorByid" runat="server"gt;删除lt;/asp:LinkButtongt;lt;/divgt;
                        </div>
                    </ItemTemplate>
                    <FooterTemplate>
                    </FooterTemplate>
                </asp:Repeater>

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

LinkButton控件的获取:

protected void rptContent_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        switch(e.CommandName)
        {
            case "replyAuthor":
                {
                    Response.Write(e.CommandArgument.ToString());
                    break;
                }
            case "deleteAuthorByid":
                {
                    Account.DeleteAccount(e.CommandArgument.ToString());
                    DataTable dt = Account.QueryAtAtClass();

                    this.rptContent.DataSource = dt;
                    this.rptContent.DataBind();
                    break;
                }
       }
    }

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