好吧,我想从下拉列表中检索值以写入我的 .cs。sqldatasource 根据他/她拥有的帐户类型返回储蓄帐户或当前帐户。
<asp:DropDownList ID="ddlPayBy2" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource2" DataTextField="accountType"
DataValueField="accountType">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:Oakhorizons %>"
SelectCommand="SELECT [accountType] FROM [SavingAccount] WHERE ([custID] = @custID)">
<SelectParameters>
<asp:SessionParameter DefaultValue="OH00002" Name="custID"
SessionField="Session["custID"]" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
好吧,它一直没有给我任何回报。我已经尝试过了,但没有返回任何内容。我总是得到 else 语句,我试图调试它说 SelectedValue = ""
if (ddlPayBy.SelectedValue == "Savings"){
account = "Savings";
}
else if (ddlPayBy.SelectedValue == "Current")
{
account = "Current";
}
else
{
Alert.Show("Please choose your account type properly");
}