I have a table with patient data, and I also have a column with a delete button. This delete button has a ConfirmButtonExtender. The problem is that ConfirmButtonExtender only works on the first row and does not work on the rest of the rows.
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<!-- Start Table -->
<table class="table table-dark">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">FullName</th>
<th scope="col">Phone</th>
<th scope="col">BirthDay</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand1">
<ItemTemplate>
<tr>
<td>
<asp:Label ID="lblID" runat="server" Text='<%# Eval("id") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblName" runat="server" Text='<%# Eval("FullName") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblPhone" runat="server" Text='<%# Eval("phone") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblDate" runat="server" Text='<%# Eval("birthDay") %>'></asp:Label>
</td>
<td>
<asp:LinkButton CssClass="btn btn-danger" ID="btnSelect" runat="server" CommandName="Select" CommandArgument='<% #Eval("id")%>'> Select</asp:LinkButton>
<asp:LinkButton CssClass="btn btn-danger" ID="btnDelete" runat="server" CommandName="Delete" CommandArgument='<% #Eval("id")%>'>Delete</asp:LinkButton>
<ajaxToolkit:ConfirmButtonExtender runat="server" ConfirmText="" BehaviorID="btnDelete_ConfirmButtonExtender" TargetControlID="btnDelete" ID="btnDelete_ConfirmButtonExtender"></ajaxToolkit:ConfirmButtonExtender>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
<!-- End Table -->
code C#
protected void Repeater1_ItemCommand1(object source, RepeaterCommandEventArgs e)
{
if(e.CommandName == "Delete")
{
string id = e.CommandArgument.ToString();
int idPatient = Convert.ToInt32(id);
Model1 model = new Model1();
var patint = model.Patients.Find(idPatient);
model.Patients.Remove(patint);
model.SaveChanges();
clearInput();
Page_Load(source, e);
}
}
I found the solution to the problem, just remove the BehaviorID property from ajaxToolkit:ConfirmButtonExtender