In my usercontrol, I have a repeater that contains some data from the DB. Here’s the Item Template
<ItemTemplate>
<tr>
<td class="tblCell">
<a href="Document.aspx?docId=<%# Eval("DOCID") %>" target="_blank">
<%# Eval("FILENAME") %></a>
</td>
<td class="tblCell">
<asp:Label ID="_empty" runat="server" />
<asp:LinkButton ID="_lnkDelete" runat="server" OnCommand="LinkDelete_Click" CommandArgument='<%# Eval("DOCID") %>' Text="Delete" OnClientClick="return confirm('Delete this Document?')" />
</td>
</tr>
</ItemTemplate>
The Repeater shows a list of files, and each filename has it’s own delete button. The delete button however, doesn’t call the OnCommand event when clicked. It just posts back.
protected void LinkDelete_Click(object sender, CommandEventArgs e)
{
MyObject _myObj = new MyObject(Convert.ToInt64(e.CommandArgument));
_myObj.Deleted = "Y";
_myObj.Update();
DeleteFile(_myObj.Filename);
GetFileInfo();
}
Is there some problem with using a LinkButton in this way within a user control? If so, is there some workaround? Or is the problem obvious, and I’m just not seeing it?
Thanks
You have forgotten to define the CommandName. In your situationdeletewould be appropriate.EDIT: You should catch it in the Repeater’s OnItemCommand.