I have a web form with some text box and some RequiredFieldValidator like Below:
![http://uupload.ir/files/u33y_course.png](https://i.imgur.com/45YivoC.png)
in my code, I have a variable that name is session. if the session is 1 in my web form just show the highlight controls and another one visible is false. if the session is 2, the visible properties of controls are true and the second column is displayed and if the session is 3 the third one is shown.
Now the problem happens when the session is 1 or 2. after that I want to insert the data of controls to my DB, the inserting do correctly but in my web form I see all of the RequiredFieldValidator like below:
![http://uupload.ir/files/7xq_course2.png](https://i.imgur.com/Ns9m6VU.png)
How can I fix this problem?
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="ListWeekDay3"
ErrorMessage="*" ForeColor="Red" ValidationGroup="Validate1"></asp:RequiredFieldValidator>
<asp:DropDownList ID="ListWeekDay3" runat="server" ValidationGroup="Validate1" Visible="False"
Width="94px" Height="26px" TabIndex="7">
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
</td> </tr>
<tr>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="ListWeekDay2"
ErrorMessage="*" ForeColor="Red" ValidationGroup="Validate1"></asp:RequiredFieldValidator>
<asp:DropDownList ID="ListWeekDay2" runat="server" ValidationGroup="Validate1" Visible="False"
Width="94px" Height="26px" TabIndex="7">
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="ListWeekDay1"
ErrorMessage="*" ForeColor="Red" ValidationGroup="Validate1"></asp:RequiredFieldValidator>
<asp:DropDownList ID="ListWeekDay1" runat="server" ValidationGroup="Validate1" Visible="False"
CssClass="auto-style5" Width="94px" Height="26px" TabIndex="7">
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
</td>
<p>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" ValidationGroup="Validate1" />
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "1")
{
ListWeekDay1.Visible = true;
}
else if (TextBox1.Text == "2")
{
ListWeekDay1.Visible = true;
ListWeekDay2.Visible = true;
}
else if (TextBox1.Text == "3")
{
ListWeekDay1.Visible = true;
ListWeekDay2.Visible = true;
ListWeekDay3.Visible = true;
}
else
{
ListWeekDay1.Visible = false;
ListWeekDay2.Visible = false;
ListWeekDay3.Visible = false;
}
}