2013-07-03 48 views
1

我想驗證嵌套控件中的GridView中的RadioButton列表 但驗證不起作用! 這裏是我的UI: 如何驗證嵌套gridview中的控件?

 <asp:gridview runat="server" id="gvGroups" cssclass="grid_noBorder" width="100%" border="0" 
     showheader="False" autogeneratecolumns="False"> 
      <Columns> 
       <asp:TemplateField > 
        <ItemTemplate> 
         <uc1:wucInspection_GroupElements ID="wucInspection_GroupElements1" formGroupID='<%#Eval("FormGroupID") %>' taskID='<%# GetTaskID() %>' runat="server" /> 
        </ItemTemplate> 
       </asp:TemplateField> 
      </Columns> 
      <EmptyDataTemplate > 
       <table width="100%" border="0" cellpadding="0" cellspacing="0"> 
       <tr> 
       <td align="center" class="formLabelTd"> 
       <asp:Label ID="lblNoData" runat="server" meta:resourcekey="lblNoDataResource" /> 
       </td> 
       </tr> 
       </table> 
      </EmptyDataTemplate> 
     </asp:gridview> 

    </td> 
</tr> 
<tr> 
    <td colspan="4" class="formButton"> 
     <asp:button id="btnSend" runat="server" ValidationGroup="Send" meta:resourcekey="btnSendResource" cssclass="btn" 
      onclick="btnSend_Click" /> 
     <asp:button id="btnSave" runat="server" meta:resourcekey="btnSaveResource" cssclass="btn" 
      onclick="btnSave_Click" /> 
     <dev:backbutton id="btnBack" runat="server" cssclass="btn" text='<%$ Resources:SCTACommonMessages,Back %>' /> 
    </td> 
</tr> 

,這是嵌套控制:

<asp:gridview runat="server" id="gvElements" autogeneratecolumns="False" cssclass="grid_tbl" 
      headerstyle-cssclass="grid_titlebg" datakeynames="FormElementID" width="100%"     
      pagesize="15" GridLines="None" > 
       <Columns>       
        <asp:TemplateField meta:resourcekey="ElementTitleResource"> 
         <ItemTemplate > 
          <asp:Label ID="lblElementTitleLabel" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Element.ElementTitle") %>' /> 
         </ItemTemplate> 
        </asp:TemplateField> 
        <asp:TemplateField visible="false"> 
         <ItemTemplate> 
          <asp:Label ID="lblElementIDLabel" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Element.ElementID") %>' /> 
         </ItemTemplate> 
        </asp:TemplateField> 
        <asp:TemplateField visible="false"> 
         <ItemTemplate> 
          <asp:Label ID="lblFormElementIDLabel" runat="server" Text='<%# Eval("FormElementID") %>' /> 
         </ItemTemplate> 
        </asp:TemplateField> 
        <asp:TemplateField meta:resourcekey="AnswerResource"> 
         <ItemTemplate> 
          <asp:radiobuttonlist id="rblAnswer" 
          runat="server" repeatdirection="Horizontal" class="rdSelect"> 
      <asp:ListItem meta:resourcekey="listItemNoResource" Value="0" ></asp:ListItem> 
      <asp:ListItem meta:resourcekey="listItemYesResource" Value="1"></asp:ListItem>    
     </asp:radiobuttonlist> 
     <asp:requiredfieldvalidator id="rfvRblAnswer" initialvalue="-1" runat="server" Enabled ='<%# Eval("AnswerIsRequired") %>' 
      controltovalidate="rblAnswer" display="Dynamic" ValidationGroup="Send" meta:resourcekey="rfvRblAnswerResource"></asp:requiredfieldvalidator> 
         </ItemTemplate> 
        </asp:TemplateField>                  
        <asp:TemplateField meta:resourcekey="NotesResource"> 
         <ItemTemplate> 
          <dev:TextBox ID="txtNotes" MaxLength="100" runat="server" CssClass="formTextBox" /> 
         </ItemTemplate> 
        </asp:TemplateField> 
        <asp:TemplateField meta:resourcekey="AttachmentsResource"> 
        <ItemTemplate> 
        <asp:gridview runat="server" cssclass="grid_noBorder" width="100%" id="gvAttachments" autogeneratecolumns="False" ShowHeader="False"> 
        <Columns> 
        <asp:TemplateField > 
        <ItemTemplate> 
        <asp:LinkButton runat="server" Text='<%#Eval("Description") %>' PostBackURL='<%#Eval("FilePath") %>' /> 
        </ItemTemplate> 
        </asp:TemplateField> 
        </Columns> 
        <EmptyDataTemplate > 
       <table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" style="border:0;" class="formLabelTd"> 
       <asp:Label ID="lblNoAttachments" runat="server" meta:resourcekey="lblNoAttachmentsResource" /> 
       </td></tr></table> </EmptyDataTemplate> 
        </asp:gridview> 
        </ItemTemplate> 
        </asp:TemplateField> 
        <asp:TemplateField meta:resourcekey="tfEditAttachmentsResource" HeaderStyle-Width="80px"> 
        <ItemTemplate > 
         <asp:ImageButton ID="btnEdit" runat="server" OnCommand="btnAddPic_Command" 
         ImageUrl="~/_LAYOUTS/SCTAAcc2/Images/edit.png" CommandArgument='<%# Container.DataItemIndex %>' /> 

        </ItemTemplate> 
       </asp:TemplateField> 
       </Columns> 
       <EmptyDataTemplate > 
       <table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td align="center"style="border:0;" class="formLabelTd"> 
       <asp:Label ID="lblNoData" runat="server" meta:resourcekey="lblNoDataResource" /> 
       </td></tr></table> </EmptyDataTemplate> 
      </asp:gridview> 

爲什麼它不工作? 它有什麼問題?
謝謝

+0

我發現錯誤原因是:initialvalue =「 - 1」屬性,當我刪除它的驗證工作。 –

回答

0

ValidationGroupradiobuttonlist控制你在所需的驗證器給。