I have a custom validator inside a repeater
<asp:Repeater runat="server" ID="lstRepeater" >
<ItemTemplate>
<asp:CustomValidator ID="cvValid" runat="server" CssClass="error" EnableClientScript="False" ErrorMessage="Invalid."></asp:CustomValidator>
<asp:TextBox runat="server" ID="tbCustomAnswer"></asp:TextBox>
</ItemTemplate>
</asp:Repeater>
As a test, I tried the following code on an OnClick event
foreach(RepeaterItem item in lstRepeater.Items)
{
CustomValidator cvValid= (CustomValidator)item.FindControl("cvValid");
cvValid.IsValid = false;
}
As would be assumed, the error message is not displayed on the page because I didn't databind the repeater. However, as soon as re-contruct the repeater and the datasource, I lose all the old values inside the repeater. Is there an easy way around this? I can't think of an elegant way of handling this problem.