0

我有一个非常简单的表要更新。有 5 个 char(1) 列,每个列存储“Y”或“N”。这些列被命名为 Priority1.. Priority5。我创建了一个简单的更新表单,但当然默认的 EditItemTemplate 允许用户为这些列输入一个值。我想将此编辑选项更改为一个下拉菜单,他们只能为 5 列选择“Y”或“N”。这在经典的 ASP 中很简单,但我很挣扎。有人可以解释我是怎么做到的吗?

这不是一个重复的问题。我不想将下拉选项绑定到数据库字段。我想手动编码它可以是下拉列表中的 Y 或 N,并让代码抓取文本数据库字段中的任何内容。

我的表格如下。

<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" />
            &nbsp;<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>
4

0 回答 0