Note that there are some explanatory texts on larger screens.

plurals
  1. POValidating dropdownlist inside gridview control
    primarykey
    data
    text
    <p>for testing i have tried customvalidation</p> <pre><code>function ClientValidate(sender, args) { //return false for testing... args.IsValid = false; } &lt;asp:CustomValidator runat="server" ID="CustomValidator1" ControlToValidate="ddldetail" Text="Please select" ValidateEmptyText="true" ClientValidationFunction="ClientValidate" Display="Dynamic"&gt; &lt;/asp:CustomValidator&gt; </code></pre> <p>edit: here is what i exaclty wants to happen:</p> <p><img src="https://i.stack.imgur.com/L2lrf.png" alt="enter image description here"></p> <p>how to validate a dropdownlist and i have done this zillion times but what i am doing wrong here? any second pair of eye might spot it? i am trying to validate the dropdownlist if the user have not select any help?</p> <pre><code>&lt;asp:Button ID="btn" runat="server" Text="Submit" OnClick="btn_Click" CausesValidation="true"/&gt; &lt;asp:GridView ID="GVInputMapping" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" EnableModelValidation="True" onrowdatabound="GVInputMapping_RowDataBound"&gt; &lt;Columns&gt; &lt;asp:BoundField DataField="Name" ControlStyle-Width="250px" HeaderText="Name" SortExpression="Name" /&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:DropDownList runat="server" ID="ddldetail"&gt; &lt;asp:ListItem Selected="True" Value="0"&gt;Select me&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="1"&gt;abc&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="2"&gt;GHt&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;asp:RequiredFieldValidator ID="requiredDDL" runat="server" ControlToValidate="ddldetail" ErrorMessage="Please select" InitialValue="Select me" Display="Dynamic"&gt;&lt;/asp:RequiredFieldValidator&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload