mercredi 3 novembre 2021

IF Statement Using An SQL Data source in VSCode Using a SQL Connection String(ASPx)

I want to create an IF statement using ASPx, so it would look something like this:

<asp:DropDownList ID="cartype" runat="server" DataSourceID="SqlDataSource1" DataTextField="Type" DataValueField="Type">
        </asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:scifairConnectionString %>" SelectCommand="SELECT DISTINCT [Type] FROM [car]"></asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:scifairConnectionString %>" SelectCommand="SELECT DISTINCT [Make] FROM [car]{Insert IF statement here}">
            
        </asp:SqlDataSource>

Where the IF statement says that if cartype is electric(there are three types for me: electric, hybrid, and gasoline) then only show the certain makes that have electric for the type.

Here is my SQL table to make things a little easier:

SQL Data Table

And obviously there are going to be more rows, but I just haven't added them yet.

Aucun commentaire:

Enregistrer un commentaire