<asp:Repeater ID="PostRepeater" runat="server" OnItemDataBound="PostRepeater_OnItemDataBound" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<tr class="hrefTr" href="<%#Eval("EditLinkPath")%>.aspx?ChangeIDText=<%#Eval
("ProductId") %>"
style="cursor: pointer; background-color: #FCFDFE" onmouseover="style.backgroundColor='#E5EFFD'" onmouseout="style.backgroundColor='#FCFDFE'">
<td class="clickTd"><%#Eval("Order") %></td>
<td class="clickTd"><%#Eval("ProductName") %></td>
<td class="clickTd" style="height: 2px; overflow: hidden; text-overflow: ellipsis; max- 60px" onmouseover='this.title=this.innerText'>
<%#Eval("ChangeBody") %>
</td>
<td class="clickTd" style="height: 32px; overflow: hidden; text-overflow: ellipsis; max- 60px" onmouseover='this.title=this.innerText'><%#Eval("ChangeReason") %></td>
<td class="clickTd" style="height: 32px; overflow: hidden; text-overflow: ellipsis; max- 60px" onmouseover='this.title=this.innerText'><%#Eval("ChangeAffect")%></td>
<td class="clickTd"><%# Eval("Created", "{0:yyyy-MM-dd}") %></td>
<td>
<asp:ImageButton ID="imgBtnDelete" runat="server" CommandName="delete" CommandArgument='<%# Eval("ProductId") %>'
ImageUrl="../images/MyHours/Delete.gif" OnClientClick="return Confirm();" Style="display: none;" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "delete")
{
int Id = Convert.ToInt32(e.CommandArgument);
using (var site = new SPSite(weburl))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
SPList spList = web.GetList(_rootUrl + "/Lists/ChangeList/AllItems.aspx");
SPListItem item = spList.GetItemById(Id);
if (item!=null)
{
item.Delete();
Page.ClientScript.RegisterStartupScript(Page.ClientScript.GetType(), "myscript", "<script type='text/javascript'>alert('删除成功!!');</script>");
Response.Redirect(_rootUrl + "/_layouts/15/Settings/MySubmitChange.aspx");
}
}
}
}
}
protected void PostRepeater_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
ImageButton imgBtnDelete = (ImageButton)e.Item.FindControl("imgBtnDelete");
string ShowDelBtn = DataBinder.Eval(e.Item.DataItem, "ShowDelBtn").ToString();
if(ShowDelBtn=="true")
{
imgBtnDelete.Style.Add("display", "");
}
}
}