I have a very simple table to update. There are 5 char(1) columns that store either a "Y" or a "N" in each. These columns are named Priority1.. Priority5. I've created a simple update form but of course the default EditItemTemplate allows the user to type in a value for these columns. I would like to change the edit option for this to be a dropdown that they can only select "Y" or "N" for the 5 columns. This was simple in classic ASP but I'm struggling. Can someone explain how I do this?
This is not a duplicate question. I don't want to bind the dropdown options to a database field. I want to manually code that it can be a Y or a N in the dropdown list and have the code grab whatever is in the text database field.
My form is as below.
<form id="form1" runat="server">
<div>
<asp:FormView ID="FormView1" runat="server" DataKeyNames="NotificationsMatrixID" DataSourceID="SqlDataSource1">
<EditItemTemplate>
NotificationsMatrixID:
<asp:Label ID="NotificationsMatrixIDLabel1" runat="server" Text='<%# Eval("NotificationsMatrixID") %>' />
<br />
CustID:
<asp:TextBox ID="CustIDTextBox" runat="server" Text='<%# Bind("CustID") %>' />
<br />
GID:
<asp:TextBox ID="GIDTextBox" runat="server" Text='<%# Bind("GID") %>' />
<br />
EMailAddress:
<asp:TextBox ID="EMailAddressTextBox" runat="server" Text='<%# Bind("EMailAddress") %>' />
<br />
Priority1:
<asp:TextBox ID="Priority1TextBox" runat="server" Text='<%# Bind("Priority1") %>' />
<br />
Priority2:
<asp:TextBox ID="Priority2TextBox" runat="server" Text='<%# Bind("Priority2") %>' />
<br />
Priority3:
<asp:TextBox ID="Priority3TextBox" runat="server" Text='<%# Bind("Priority3") %>' />
<br />
Priority4:
<asp:TextBox ID="Priority4TextBox" runat="server" Text='<%# Bind("Priority4") %>' />
<br />
Priority5:
<asp:TextBox ID="Priority5TextBox" runat="server" Text='<%# Bind("Priority5") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<ItemTemplate>
NotificationsMatrixID:
<asp:Label ID="NotificationsMatrixIDLabel" runat="server" Text='<%# Eval("NotificationsMatrixID") %>' />
<br />
CustID:
<asp:Label ID="CustIDLabel" runat="server" Text='<%# Bind("CustID") %>' />
<br />
GID:
<asp:Label ID="GIDLabel" runat="server" Text='<%# Bind("GID") %>' />
<br />
EMailAddress:
<asp:Label ID="EMailAddressLabel" runat="server" Text='<%# Bind("EMailAddress") %>' />
<br />
Priority1:
<asp:Label ID="Priority1Label" runat="server" Text='<%# Bind("Priority1") %>' />
<br />
Priority2:
<asp:Label ID="Priority2Label" runat="server" Text='<%# Bind("Priority2") %>' />
<br />
Priority3:
<asp:Label ID="Priority3Label" runat="server" Text='<%# Bind("Priority3") %>' />
<br />
Priority4:
<asp:Label ID="Priority4Label" runat="server" Text='<%# Bind("Priority4") %>' />
<br />
Priority5:
<asp:Label ID="Priority5Label" runat="server" Text='<%# Bind("Priority5") %>' />
<br />
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" />
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Heat974ConnectionString %>" SelectCommand="SELECT * FROM [NotificationsMatrix]" UpdateCommand="UPDATE [NotificationsMatrix] SET [CustID] = @CustID, [GID] = @GID, [EMailAddress] = @EMailAddress, [Priority1] = @Priority1, [Priority2] = @Priority2, [Priority3] = @Priority3, [Priority4] = @Priority4, [Priority5] = @Priority5 WHERE [NotificationsMatrixID] = @NotificationsMatrixID">
<UpdateParameters>
<asp:Parameter Name="CustID" Type="String" />
<asp:Parameter Name="GID" Type="String" />
<asp:Parameter Name="EMailAddress" Type="String" />
<asp:Parameter Name="Priority1" Type="String" />
<asp:Parameter Name="Priority2" Type="String" />
<asp:Parameter Name="Priority3" Type="String" />
<asp:Parameter Name="Priority4" Type="String" />
<asp:Parameter Name="Priority5" Type="String" />
<asp:Parameter Name="NotificationsMatrixID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
</div>
</form>