protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Delete") { int index = e.Item.ItemIndex; Repeater1.DataSource.RemoveAt(index); Repeater1.DataBind(); } }
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { LinkButton deleteButton = (LinkButton)e.Item.FindControl("DeleteButton"); if (deleteButton != null) { deleteButton.CommandName = "Delete"; deleteButton.CommandArgument = e.Item.ItemIndex.ToString(); } } }This example shows how to update the CommandName and CommandArgument properties of a LinkButton control inside a Repeater control's ItemDataBound event. By setting the CommandName property to "Delete" and the CommandArgument property to the current item index, you can later retrieve this information in the ItemCommand event.