保存ID而不是名称

时间:2015-10-03 06:08:15

标签: c# asp.net oracle

我有哪个存储的国家/地区名称。但不是那样,我想存储国家ID。

这是我的代码: -

if (!string.IsNullOrEmpty(mkey))
        {  
          insertUpdateQuery = "UPDATE B_Order_new SET ShipName = :ShipName, ShipCity = :ShipCity, ShipAddress = :ShipAddress, " +
                                 "ShipCountry = :ShipCountry, OrderDate = :OrderDate, Sent = :Sent where MKEY = :MKEY";
        }
        else
        {
            insertUpdateQuery = "INSERT INTO B_Order_new (MKEY, ShipName, ShipCity, ShipAddress, ShipCountry, OrderDate, Sent) " +
                                 "VALUES(:MKEY, :ShipName, :ShipCity, :ShipAddress, :ShipCountry, :OrderDate, :Sent)";
        }

        OracleCommand cmd = new OracleCommand(insertUpdateQuery, myConn);

        var orderedOn = DateTime.ParseExact(orderDate, "dd/MM/yyyy", null);

        cmd.Parameters.Add("MKEY", OracleType.Number).Value = decimal.Parse(mkey).ToString();
        cmd.Parameters.Add("ShipName", OracleType.VarChar).Value = shipName;
        cmd.Parameters.Add("ShipCity", OracleType.VarChar).Value = shipCity;
        cmd.Parameters.Add("ShipAddress", OracleType.VarChar).Value = shipAddress;
        cmd.Parameters.Add("ShipCountry", OracleType.VarChar).Value = shipCountry;
        cmd.Parameters.Add("OrderDate", OracleType.DateTime).Value = orderedOn;
        cmd.Parameters.Add("Sent", OracleType.Char).Value = true;
}

另请参阅我的选择查询,了解我如何绑定它。

<asp:SqlDataSource ID="sdCombo" runat="server" ConnectionString="<%$ ConnectionStrings:OracleConn %>"
    ProviderName="<%$ ConnectionStrings:OracleConn.ProviderName %>" SelectCommand="SELECT COUNTRY_ID, COUNTRY_NAME from country_test">
</asp:SqlDataSource>

我的gridview,我绑定了该下拉列表

<obout:ComboBox runat="server" ID="ComboBoxEditor" FolderStyle="ComboBox/styles/premiere_blue"
            Width="100%" Height="150" MenuWidth="175" DataSourceID="sdCombo" DataTextField="COUNTRY_NAME"
            DataValueField="COUNTRY_NAME" OpenOnFocus="false">
            <ClientSideEvents OnBlur="persistFieldValue" OnOpen="ComboBox_Open" />
        </obout:ComboBox>

1 个答案:

答案 0 :(得分:2)

将您的ComboBox的let x = fmap (\s -> FrameworksMoment $ liftIO $ getAnotherRemoteApiValue s) appStateE remoteValue2E <- execute x 替换为sink output2,这会将country_Id加载到ComboBox,然后您可以将ComboBox的sink output2 [text :== show <$> remoteValue2B] 分配给(\s -> FrameworkMoment $ liftIO $ getAnotherRemoteApiValue s)变量,用于存储国家/地区同上

修改:您可以将其指定为:

FrameworkMoment

将ComboBox的脚本更改为:

DataValueField="COUNTRY_NAME"