Note that there are some explanatory texts on larger screens.

plurals
  1. POasp.net Validation on DropDownList box
    primarykey
    data
    text
    <p>I have a dropdownlist (cboViewAlbums) which has displays album values. The first item is a <strong>Please select an album...</strong>. I am trying to use validation which when lb_create_album linkButton is clicked throws an error if the cboViewAlbums list has the value 0 selected. Below is the code for the this and my attempt:</p> <pre><code>&lt;asp:DropDownList ID="cboViewAlbums" runat="server" DataSourceID="SqlDataSource1" DataTextField="album_name" DataValueField="album_id" Width="250px" AutoPostBack="True" AppendDataBoundItems="true"&gt; &lt;asp:ListItem Value="0"&gt;Please select an album...&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;asp:LinkButton ID="lb_create_album" runat="server"&gt;Create Album&lt;/asp:LinkButton&gt; &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:fpaConnectionString %&gt;" SelectCommand="SELECT [album_id], [album_name] FROM [fpa_albums] ORDER BY [album_name]"&gt; &lt;/asp:SqlDataSource&gt; &lt;br /&gt; &lt;asp:HyperLink CssClass="example7" ID="hLinkUploadPhotos" NavigateUrl="multiple_upload.aspx" runat="server"&gt;Upload Multiple Photos&lt;/asp:HyperLink&gt; &lt;br /&gt; &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="cboViewAlbums" ErrorMessage="Please Select an Album" InitialValue="Please select an album..."&gt;&lt;/asp:RequiredFieldValidator&gt; </code></pre> <p>Any idea how I can get this working? </p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    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