Rahul Lakshakar

Rahul Lakshakar

  • NA
  • 199
  • 41.8k

required field validator not working

Jul 1 2017 6:53 AM
 I am trying to validate to inittial value in dropdwinlist using required filed validator but it is not working. please help any one
 
 
<table id="tbl_AddmsnDetail" class="inner_tbl">
<tr>
<td class="td1">
<p><span style="color: red;">*</span> Select Course :<br />
&nbsp (????? ????? ?????? ??????)</p>
</td>
<td class="td1">
<asp:DropDownList ID="drpdwn_SelectCourse" AppendDataBoundItems="true" CausesValidation="true" AutoPostBack="true" CssClass="inner-dropdown" runat="server" DataSourceID="SqlDataSource5" DataTextField="CourseName" DataValueField="CourseID" OnSelectedIndexChanged="drpdwn_SelectCourse_SelectedIndexChanged">
<asp:ListItem> --- Pick One --- </asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:iDiary_RBSCollegeConnectionString1 %>" SelectCommand="SELECT [CourseName],[CourseID] FROM [CourseMaster] WHERE ([Admission_Open_Trigger] = @Admission_Open_Trigger) ORDER BY [CourseID]">
<SelectParameters>
<asp:Parameter DefaultValue="1" Name="Admission_Open_Trigger" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:RequiredFieldValidator Font-Size="9px" ForeColor="Red" ID="RequiredFieldValidator1" runat="server"
ErrorMessage="Please select" ControlToValidate="drpdwn_SelectCourse"
InitialValue="--- Pick One ---"></asp:RequiredFieldValidator>
<asp:Label ID="lbl_courseid" runat="server" Visible="false" Text="Label"></asp:Label>
<asp:Label ID="lbl_coursetype" runat="server" Visible="false" Text="Label"></asp:Label>
</td>
<td class="td1">
<p><span style="color: red;">*</span> Select Group :<br />
&nbsp (????? ?? ??? ???)</p>
</td>
<td class="td1">
<asp:DropDownList ID="drpdwn_group" AutoPostBack="true" DataTextField="GrpName" CssClass="inner-dropdown" OnSelectedIndexChanged="drpdwn_group_SelectedIndexChanged" runat="server">
</asp:DropDownList>
</td>
</tr>
</table>
<table id="subject_typ1" runat="server" visible="false">
<tr>
<td class="td1">
<p><span style="color: red;">*</span> Select Subject1 :<br />
&nbsp (????)</p>
</td>
<td class="td1">
<asp:DropDownList ID="drpdwn_SelectSubject1" CssClass="inner-dropdown" runat="server" DataTextField="SubjectName" DataValueField="SubjectName">
<asp:ListItem> --- Pick One --- </asp:ListItem>
</asp:DropDownList>
<br />
<asp:RequiredFieldValidator CssClass="validator" ID="RequiredFieldValidator10" runat="server"
ErrorMessage="Please select" ControlToValidate="drpdwn_SelectSubject1"
InitialValue="--- Pick One ---"></asp:RequiredFieldValidator>
</td>
<td class="td1">
<p><span style="color: red;">*</span> Select Subject2 :<br />
&nbsp (????)</p>
</td>
<td class="td1">
<asp:DropDownList ID="drpdwn_SelectSubject2" CssClass="inner-dropdown" runat="server" DataTextField="SubjectName" DataValueField="SubjectName">
<asp:ListItem> --- Pick One --- </asp:ListItem>
</asp:DropDownList>
<br />
<asp:RequiredFieldValidator CssClass="validator" ID="RequiredFieldValidator11" runat="server"
ErrorMessage="Please select" ControlToValidate="drpdwn_SelectSubject2"
InitialValue="--- Pick One ---"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="td1">
<p><span style="color: red;">*</span> Select Subject3 :<br />
&nbsp (????)</p>
</td>
<td class="td1">
<asp:DropDownList ID="drpdwn_SelectSubject3" CssClass="inner-dropdown" runat="server" DataTextField="SubjectName" DataValueField="SubjectName">
<asp:ListItem> --- Pick One --- </asp:ListItem>
</asp:DropDownList>
<br />
<asp:RequiredFieldValidator CssClass="validator" ID="RequiredFieldValidator12" runat="server"
ErrorMessage="Please select" ControlToValidate="drpdwn_SelectSubject3"
InitialValue="--- Pick One ---"></asp:RequiredFieldValidator></td>
<td class="td1">
<p><span style="color: red;">*</span> Select Subject4 :<br />
&nbsp (????)</p>
</td>
<td class="td1">
<asp:DropDownList ID="drpdwn_SelectSubject4" CssClass="inner-dropdown" runat="server" DataTextField="SubjectName" DataValueField="SubjectName">
<asp:ListItem> --- Pick One --- </asp:ListItem>
</asp:DropDownList>
<br />
<asp:RequiredFieldValidator CssClass="validator" ID="RequiredFieldValidator13" runat="server"
ErrorMessage="Please select" ControlToValidate="drpdwn_SelectSubject4"
InitialValue="--- Pick One ---"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td class="td1">
<p><span style="color: red;">*</span> Select Subject5 :<br />
&nbsp (????)</p>
</td>
<td class="td1">
<asp:DropDownList ID="drpdwn_SelectSubject5" CssClass="inner-dropdown" runat="server" DataTextField="SubjectName" DataValueField="SubjectName">
<asp:ListItem> --- Pick One --- </asp:ListItem>
</asp:DropDownList>
<br />
<asp:RequiredFieldValidator CssClass="validator" ID="RequiredFieldValidator14" runat="server"
ErrorMessage="Please select" ControlToValidate="drpdwn_SelectSubject5"
InitialValue="--- Pick One ---"></asp:RequiredFieldValidator></td>
<td class="td1">
<p><span style="color: red;">*</span> Select Subject6 :<br />
&nbsp (????)</p>
</td>
<td class="td1">
<asp:DropDownList ID="drpdwn_SelectSubject6" CssClass="inner-dropdown" runat="server" DataTextField="SubjectName" DataValueField="SubjectName">
<asp:ListItem> --- Pick One --- </asp:ListItem>
</asp:DropDownList>
<br />
<asp:RequiredFieldValidator CssClass="validator" ID="RequiredFieldValidator15" runat="server"
ErrorMessage="Please select" ControlToValidate="drpdwn_SelectSubject6"
InitialValue="--- Pick One ---"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td class="td1">
<p><span style="color: red;">*</span> Select Subject7 :<br />
&nbsp (????)</p>
</td>
<td class="td1">
<asp:DropDownList ID="drpdwn_SelectSubject7" CssClass="inner-dropdown" runat="server" DataTextField="SubjectName" DataValueField="SubjectName">
<asp:ListItem> --- Pick One --- </asp:ListItem>
</asp:DropDownList>
<br />
<asp:RequiredFieldValidator CssClass="validator" ID="RequiredFieldValidator16" runat="server"
ErrorMessage="Please select" ControlToValidate="drpdwn_SelectSubject7"
InitialValue="--- Pick One ---"></asp:RequiredFieldValidator></td>
<td class="td1">
<p><span style="color: red;">*</span> Select Subject8 :<br />
&nbsp (????)</p>
</td>
<td class="td1">
<asp:DropDownList ID="drpdwn_SelectSubject8" CssClass="inner-dropdown" runat="server" DataTextField="SubjectName" DataValueField="SubjectName">
<asp:ListItem> --- Pick One --- </asp:ListItem>
</asp:DropDownList>
<br />
</td>
</tr>
</table>
<table id="subject_type2" runat="server">
<tr>
<td>
<asp:DataList ID="DataList2" Visible="false" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:Label Text='<%# Container.ItemIndex + 1 %>' runat="server" ID="Label12" />-
<asp:Label Text='<%# Eval("SubjectName") %>' runat="server" ID="SubjectNameLabel" /><br />
<br />
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString='<%$ ConnectionStrings:iDiary_RBSCollegeConnectionString1 %>' SelectCommand="SELECT [SubjectName] FROM [SubjectsMaster] WHERE ([CourseID] = @CourseID)">
<SelectParameters>
<asp:SessionParameter SessionField="courseid" Name="CourseID" Type="Int32"></asp:SessionParameter>
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
</table>
<%--<tr id="MSc_Ag">
<td class="td1">
<p> Enter Subject for M.Sc.(Ag) :</p>
</td>
<td class="td1">
<p>1.)</p><asp:TextBox ID="TextBox2" CssClass="inner-textbox" runat="server"></asp:TextBox>
</td>
<td class="td1">
<p>2.)</p><asp:TextBox ID="TextBox7" CssClass="inner-textbox" runat="server"></asp:TextBox>
</td>
<td class="td1">
<p>3.)</p><asp:TextBox ID="TextBox8" CssClass="inner-textbox" runat="server"></asp:TextBox>
</td>
</tr>--%>
<table>
<tr>
<td class="td1" colspan="4" style="text-align: right">
<asp:Button ID="next2" runat="server" CssClass="btn" CausesValidation="true" Text="Save & Next" OnClick="next2_Click" />
</td>
</tr>
</table>

Answers (3)