views:

684

answers:

1

I have a page that has a listview that is used for inserting and editing records. Assigning a RequiredFieldValidator and ValidatorCallOutExtender to the InsertItemTemplate works well.
When I try to do the same on the EditItemTemplate the ValidatorCallOut appears but with no text in the box. Is there something that I'm doing wrong?

My code for the InsertItemTemplate:

 <asp:TextBox ID="date_timeTextBox" runat="server" Text='<%# Bind("date_time") %>' />
 <asp:RequiredFieldValidator 
      ControlToValidate="date_timeTextBox" 
      ID="RequiredFieldValidator1" 
      runat="server" 
      ErrorMessage="date_time is required" 
      Display="None" 
      ValidationGroup="insert_into">
 </asp:RequiredFieldValidator>
 <cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" 
      runat="server" 
      TargetControlID="RequiredFieldValidator1">
 </cc1:ValidatorCalloutExtender>

And for the EditItemTemplate:

<asp:TextBox 
    ID="date_timeTextBox" 
    runat="server" 
    Text='<%# Bind("date_time","{0:yyyy-MM-dd}") %>' />
<asp:RequiredFieldValidator 
    ControlToValidate="date_timeTextBox" 
    ID="reqDTT"       
    runat="server" 
    ErrorMessage="date_time is required" 
    Display="None" 
    ValidationGroup="edit_validate">
</asp:RequiredFieldValidator>
<cc1:ValidatorCalloutExtender 
    ID="val_reqDTT" 
    runat="server" 
    TargetControlID="reqDTT">
</cc1:ValidatorCalloutExtender>
A: 

Make sure your ID's are unique across your Templates, so the ControlToValidate="date_timeTextBox" is different.

InsertTemplate

 <asp:TextBox ID="date_timeTextBoxInsert" runat="server" Text='<%# Bind("date_time") %>' />

EditTemplate

 <asp:TextBox ID="date_timeTextBoxEdit" runat="server" Text='<%# Bind("date_time") %>' />
rick schott
ThanksA secondary issue was the color of the EditItemTemplate rows (TR) was set to white (FFFFFF) which makes the text really hard to see on the default yellow background.
John M