Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to validate dropdownlist control inside the gridview
    text
    copied!<p>edit:</p> <pre><code>var dropDownControls = $('#&lt;%=GridView1.ClientID %&gt; select option:selected'); var checkbox = $.......checkbox ..... for(index = 0; index &lt; dropDownControls.length; index++) { if (checkbox.checked) //my code gets exaclty what checkbox i checked { if(dropDownControls[index].selectedIndex == 0) { flag = false; break; } } } </code></pre> <p>the above code works</p> <p>i have my button outside the gridivew and i am trying to validate the dropdownlist which is inside the gridivew.</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:CheckBox id="checkbox1" runat="server"/&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>
 

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