如何将Requiredfieldvalidator控件添加到formview itemtemplate

时间:2012-09-14 05:59:13

标签: asp.net

如何添加(绑定)Requiredfieldvalidator控件到formview itemtemplate?

   

     <tr runat="server" > 
         <td style="width: 120px">

             <asp:Label Text="Purchase Org.:" ID="LabelPurchOrg1" runat="server">  </asp:Label>
       </td>
        <td>
            <orbit:Control runat="server" ID="Purch" Text='<%# Eval("Site")%>'                    LabelPosition="Right" CssClassLabel="SectionTextLookup"   RenderTextBoxAsLabel="true" EnableLabel="true" EnableTooltip="true" LookupCommand="sit" />

           <asp:RequiredFieldValidator ID="PurchaseOrg" runat="server" ControlToValidate='<%#   Eval("Site") %>'   ErrorMessage="<" EnableClientScript="false" Enabled="false" >
        </asp:RequiredFieldValidator>
      </td>
  </tr>
</table>
</ItemTemplate>

1 个答案:

答案 0 :(得分:0)

所以你只需要更改RequiredFieldValidator,如下所示:

<asp:RequiredFieldValidator ID="PurchaseOrg" runat="server" 
ControlToValidate="Purch" ErrorMessage="<" EnableClientScript="false" 
Enabled="false" ></asp:RequiredFieldValidator>