Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use <code>GridView1.Rows(0)</code> to get the first row:</p> <pre><code>Dim firstRow = GridView1.Rows(0) Dim TextBox2 = DirectCast(firstRow.FindControl("TextBox2"), TextBox) Dim DropDownList3 = DirectCast(firstRow.FindControl("DropDownList3"), DropDownList) If TextBox2.Text.Trim.Length = 0 OrElse DropDownList3.SelectedIndex = -1 Then label6.Text = "HospNo,Date,SurgeryCode/Method are Mandatory" End If </code></pre> <p>But this is not the approach you should use in ASP.NET. Instead use <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.requiredfieldvalidator%28v=vs.100%29.aspx" rel="nofollow"><code>RequiredFieldValidator</code></a> which can ven validate on client-side.</p> <p>For example:</p> <pre><code>&lt;asp:GridView ID="GridView1" OnSelectedIndexChanged="Grid1_SelectedIndexChanged" AutoGenerateSelectButton="true" AutoGenerateColumns="false" runat="server" Width="300"&gt; &lt;RowStyle CssClass="GridViewRowStyle" /&gt; &lt;AlternatingRowStyle CssClass="GridViewAlternatingRowStyle" /&gt; &lt;HeaderStyle CssClass="GridViewHeaderStyle" /&gt; &lt;SelectedRowStyle BackColor="Aqua" /&gt; &lt;Columns&gt; &lt;asp:TemplateField HeaderText="Column 1" HeaderStyle-HorizontalAlign="Left"&gt; &lt;ItemTemplate&gt; &lt;asp:TextBox runat="server" ID="TxtColumn1" Text='&lt;%# Bind("Column1") %&gt;'&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator id="RequiredFieldValidator1" EnableClientScript="true" ControlToValidate="TxtColumn1" Display="Static" ErrorMessage="HospNo,Date,SurgeryCode/Method are Mandatory" runat="server"/&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