1

嗨,我是 ASP 新手,能够创建一个下拉列表,其中列出了我表中的所有项目(DB2_INSTANCES)

现在我需要PROCESS使用选定的 DB2_DSN 值更新第二个表 ( )。The table does not allow Null values.

如果我"SelectedValue='<%# Bind("DB2_DSN") %>'asp:DropDownList我设置后使用

DataSourceID="SqlDataSource6" DataTextField="INSTANCE" DataValueField="INSTANCE"

我收到一个错误:

“'DropDownList6' 有一个无效的 SelectedValue,因为它不存在于项目列表中。参数名称:值”

"SelectedValue='<%# Bind("INSTANCE") %>'如果我asp:DropDownList在设置后更改为

DataSourceID="SqlDataSource6" DataTextField="INSTANCE" DataValueField="INSTANCE"

我收到一个错误:

“DataBinding:‘System.Data.DataRowView’不包含名为‘INSTANCE’的属性。”

如果我删除“ SelectedValue...”,我会收到错误消息:

无法将值 NULL 插入列“DB2_DSN”、表“xxx.dbo.PROCESS”;列不允许空值。更新失败。该语句已终止。

我也尝试过使用,DataBind()但它也给了我一个错误。另一个值(FTP_IND)可以正常工作,因为它是列出/硬编码的。为什么它适用于FTP_IND而不适用于DB2_DSN

第一的:

<asp:SqlDataSource ID="SqlDataSource3" runat="server" 
    ConnectionString="<%$ ConnectionStrings:xxxConnectionString2 %>" 
    DeleteCommand="DELETE FROM PROCESS WHERE NAME = @NAME AND ENVIRONMENT =   @ENVIRONMENT"
    SelectCommand="SELECT * FROM [PROCESS]" 
    UpdateCommand="UPDATE PROCESS SET ENVIRONMENT = @ENVIRONMENT, PROCESS_STATUS = @PROCESS_STATUS, IC_VALUE = @IC_VALUE, 
    FTP_IND = @FTP_IND, DB2_DSN = @DB2_DSN, DB2_REGION = @DB2_REGION, 
    ALERT_EMAIL = @ALERT_EMAIL, NOTIFY_EMAIL = @NOTIFY_EMAIL, DEBUG_INFO = @DEBUG_INFO, 
    LAST_UPDATE_DATE = CURRENT_TIMESTAMP, LAST_UPDATE_USERID = @UID, LAST_UPDATE_IP = @UIP WHERE (NAME = @NAME)">
        <UpdateParameters>
        <asp:SessionParameter Name="UID" SessionField="User_ID" Type="String" />
        <asp:SessionParameter Name="UIP" SessionField="User_IP" Type="String" />
        <asp:Parameter Name="ENVIRONMENT" />
        <asp:Parameter Name="PROCESS_STATUS" />
        <asp:Parameter Name="IC_VALUE" />
        <asp:Parameter Name="FTP_IND" />
        <asp:Parameter Name="DB2_DSN" />
        <asp:Parameter Name="DB2_REGION" />
        <asp:Parameter Name="ALERT_EMAIL" />
        <asp:Parameter Name="NOTIFY_EMAIL" />
        <asp:Parameter Name="DEBUG_INFO" />
        <asp:Parameter Name="NAME" />
    </UpdateParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource6" runat="server" 
    ConnectionString="<%$ ConnectionStrings:xxxConnectionString2 %>" 
    SelectCommand="SELECT [INSTANCE] FROM [DB2_INSTANCES] ORDER BY [INSTANCE] ASC">
</asp:SqlDataSource>

第二:

<asp:TemplateField HeaderText="FTP" SortExpression="FTP_IND">
            <EditItemTemplate>
                <asp:DropDownList ID="DropDownList5" runat="server"  
                    SelectedValue='<%# Bind("FTP_IND") %>' 
                    ToolTip="Use this to turn off and on the FTP process" Font-Size="Small">
                    <asp:ListItem>N</asp:ListItem>
                    <asp:ListItem>Y</asp:ListItem>
                </asp:DropDownList>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label11" runat="server" Text='<%# Bind("FTP_IND") %>' 
                    ToolTip="Indicates if FTP will take place" Font-Size="Small">
                </asp:Label>
            </ItemTemplate>
            <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
        </asp:TemplateField>

        <asp:TemplateField HeaderText = "DB2 Instance" SortExpression="DB2_DSN">
            <EditItemTemplate>
                <asp:DropDownList ID="DropDownList6" runat="server" 
                    ToolTip="Use this to choose the DB2 Instance" Font-Size="Small" 
                    DataSourceID="SqlDataSource6"
                    DataTextField="INSTANCE" 
                    DataValueField="INSTANCE">
                 </asp:DropDownList>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label12" runat="server" Text='<%# Bind("DB2_DSN") %>'
                    ToolTip="Indicates the DB2 Instance being used" Font-Size="Small">
                </asp:Label>
            </ItemTemplate>
            <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
4

0 回答 0