It has the following relay control with a list of flags:
<asp:Repeater ID="rptItemList" runat="server"> <HeaderTemplate> </HeaderTemplate> <ItemTemplate> <div> <asp:CheckBox ID="chkItem" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ItemName").ToString() %>' /> <asp:HiddenField ID="hdItem" runat="server" Value='<%# DataBinder.Eval(Container.DataItem, "ItemId").ToString() %>' /> </div> </ItemTemplate> <FooterTemplate> <asp:LinkButton ID="lbtnDel" runat="server" Text="Delete" OnClick="lbtnDel_Click" OnClientClick="return confirm('Are you sure you want to delete selected items from this list?')"></asp:LinkButton> </FooterTemplate> </asp:Repeater>
and the following reverse code to handle the lbtnDel_Click event:
protected void lbtnDel_Click(object sender, EventArgs e) { foreach (RepeaterItem ri in rptItemList.Items) { CheckBox chk = (CheckBox)ri.FindControl("chkItem"); HiddenField hd = (HiddenField)ri.FindControl("hdItem"); if (chk.Checked) { var tc = new ItemController(); tc.DeleteItem(Convert.ToInt32(hd.Value)); } } Response.Redirect(DotNetNuke.Common.Globals.NavigateURL()); }
When I select the check box and click the "Delete" button, the code finds the check box, but reads it as unchecked, so it does not delete the item.
Any ideas?
source share