2009-12-23 66 views
1

我在gridview中使用dropdownlist控件和一個RequiredFieldValidator控件。DropDownList和RequiredFieldValidator控件

<asp:DropDownList ID="ddlInsert" runat="server" CssClass="normal" DataSourceID="sqlDataSource" DataTextField="Name" DataValueField="ID" SelectedValue='<%# Bind("ID") %>' AppendDataBoundItems="true"> 
       <asp:ListItem Text="--Select--" Value="-1" Selected="True" /> 
       </asp:DropDownList> 
       <asp:RequiredFieldValidator ID="requiredDDL" runat="server" ControlToValidate="ddlInsertRegion" ErrorMessage="*" InitialValue="-1" Display="Dynamic"></asp:RequiredFieldValidator> 

但這種驗證是不工作

+0

我想他不應該。 B-Rain的回答是正確的,我用無數據源的DDL驗證了它。 – Webleeuw 2009-12-23 11:19:31

回答

2

的ControlToValidate = 「ddlInsertRegion」 的驗證,但DropDownList控件ID是ID = 「ddlInsert」

+0

謝謝。我錯過了validationgroup屬性。 – Geetha 2009-12-23 11:59:43

相關問題