I cannot get the ConfirmButtonExtender to work in a DataList ItemTemplate. I get the infamous error can't find control id (of the target control of course).
I checked all the normal causes and I don't see what is wrong. They are both in the item template, hence the same naming container.
Here is a sample of what I have:
<asp:DataList ID="relList" runat="server" BorderColor="#5377A9" BorderStyle="Double" Width="100%" ExtractTemplateRows="True" OnItemCreated="relList_ItemCreated"> <ItemTemplate> <asp:Table ID="tblSubFMEAs" runat="server"> <asp:TableRow ID="SubFMEARow" runat="server"> <asp:TableCell ID="SubFMEANameCell" runat="server" Width="80%"> <div style="padding:2px; vertical-align: middle; text-indent: 10px;"> <asp:linkbutton ID="nameLabel" runat="server" Text='<%# GetLinkLabelText(Container)%>' CommandName="Edit" /><br /> </div> </asp:TableCell> <asp:TableCell ID="RemSubFMEACell" runat="server" Width="20%" HorizontalAlign="Right"> <div style="padding:2px; vertical-align: middle; direction: rtl; text-indent: 10px;"> <asp:LinkButton ID="RemoveSubFMEA" runat="server" Text="Remove" CommandName="Remove" /> <cc1:ConfirmButtonExtender ID="confirmRem" runat="server" TargetControlID="RemoveSubFEMA" /> </div> </asp:TableCell> </asp:TableRow> </asp:Table> </ItemTemplate> <FooterTemplate> <asp:Table ID="tblSubFMEAsFooter" runat="server"> <asp:TableRow ID="SubFMEAFooterRow" runat="server"> <asp:TableCell ID="FooterCell" runat="server"> <img alt=" " src="images/dot.gif" height="1" /> </asp:TableCell> </asp:TableRow> </asp:Table> </FooterTemplate> </asp:DataList>
Hi CHolt,
there are two issues...
1. The ConfirmButtonExtender cant put in the <ItemTemplate> , you need to move it out of DataList. Otherwise you error on Design View
2. Once you move it out of DataList, you will getThe TargetControlID of 'confirmRem' is not valid. A control with ID 'RemoveSubFMEA' could not be found.
This is because the DataList created after ConfirmButtonExtender generated. So it can not find the TargetControlID. To walkwround it you may add ConfirmButtonExtender by code. Add it on page_Load
Hope this help
On thing that confuses me about your solution is that the button will be repeated. How is the extender going to work with multiple targets?
I would think that this is the most common use of the confirmbuttonextender to have a confirm dialog on the delete "button" of a row in a datalist or gridview. Is there any examples out there that have this working?
Thanks
No comments:
Post a Comment