1 <asp:Repeater ID="repComment" runat="server"
2 onitemdatabound="repComment_ItemDataBound">
3 <ItemTemplate>
4 <div class="replay">
5 <p class="con">
6 <%#Eval("content") %>
7 </p>
8 <p class="replay_info">
9 <asp:LinkButton ID="lbtnDelComment" OnClientClick="return confirm('是否要真的删除该评论?')" onclick="lbtnDelComment_Click" CommandArgument='<%# Eval("id") %>' runat="server" Visible="false">删除</asp:LinkButton>
10 评论者:<%# Eval("userIp").ToString().Substring(0, Eval("userIp").ToString().LastIndexOf(".")+1) + "*"%> 评论时间:<%#Eval("createTime") %></p>
11 <hr />
12 </div>
13 </ItemTemplate>
14 </asp:Repeater>
1 // 根据session的值显示或者隐藏删除评论的按钮
2 protected void repComment_ItemDataBound(object sender, RepeaterItemEventArgs e)
3 {
4 if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
5 {
6 // 判断session的值显示或者隐藏删除评论的按钮
7 if (Session["admin"] != null && Session["admin"].ToString() == "niunan")
8 {
9 ((LinkButton)e.Item.FindControl("lbtnDelComment")).Visible = true;
10 }
11 }
12 }
转自:http://blog.csdn.net/stitch_kwok/article/details/5327751