如何验证嵌套网格视图中的控件

本文关键字:视图 网格 控件 嵌套 何验证 验证 | 更新日期: 2023-09-27 18:20:58

我正在尝试验证嵌套控件中网格视图中的RadioButton列表但验证无效!这是我的UI:

        <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>

为什么它不起作用?它怎么了
感谢

如何验证嵌套网格视图中的控件

radiobuttonlist控件中给定ValidationGroup,该控件是在所需的验证器中给定的。