我收到一條錯誤消息,說明CheckBox1
未被聲明,但它肯定是在gridview
之前。背景是用戶正在批准gridview
中的記錄。如果記錄未被批准,則複選框未被選中。因爲它沒有被批准,我還想要求用戶解釋原因的評論。 只有當複選框未選中時,才需要註釋。聲明CheckBox顯示爲未驗證器中的未聲明
我試過轉移驗證器周圍,但我沒有任何運氣。有什麼我失蹤?對於asp.net
仍然很新穎。後端是vb.net
。以下是評論欄。如果需要更多,請讓我知道。
的錯誤:
'CheckBox1' is not declared. It may be inaccessible due to its protection level.
驗證碼:
<asp:TemplateField HeaderText="Comment">
<ItemTemplate>
<asp:TextBox ID="Comment" MaxLength="200" runat="server" Width="500px" Text='<%# Eval("Comment") %>'></asp:TextBox>
<asp:RegularExpressionValidator
Display = "Dynamic"
ControlToValidate = "Comment"
ID="RegularExpressionValidator"
ValidationExpression = "^[a-zA-Z0-9'@&#.\s]{2,200}$"
runat="server"
ForeColor="red"
ErrorMessage="!">
</asp:RegularExpressionValidator>
<%If CheckBox1.Checked = "False" then%>
<asp:RequiredFieldValidator id="RequiredFieldValidator" runat="server"
ControlToValidate="Comment"
ErrorMessage="*Required"
ForeColor="Red">
</asp:RequiredFieldValidator>
<%Else%>
<%End If%>
</ItemTemplate>
</asp:TemplateField>
您無法訪問GridView模板中的其他控件。 – VDWWD