在使用表中的连接列值填充列表框时,如何检索相应的 ID 并传递值 onchange [关闭]

Posted

技术标签:

【中文标题】在使用表中的连接列值填充列表框时,如何检索相应的 ID 并传递值 onchange [关闭]【英文标题】:While populating a list box with concatenated columns values from table, How to retrieve corresponding ID and pass the value onchange [closed] 【发布时间】:2013-08-02 14:21:07 【问题描述】:

这是我的带有串联列的下拉选择框。如何检索记录的 ID 并将该值传递给 onchange?

<asp:DropDownList 
    ID="DropDownList2" 
    runat="server" 
    DataSourceID="AccessDataSource1" 
    DataTextField="Expr1" 
    DataValueField="Expr1">
</asp:DropDownList>
<asp:AccessDataSource 
    ID="AccessDataSource1" 
    runat="server" 
    DataFile="~/tools/tracker/Tracker.mdb" 
    SelectCommand="SELECT PAcronym + ' - ' + Milestone + ' (' + PRelease + ')' AS Expr1 FROM Projects ORDER BY PAcronym + ' - ' + Milestone + ' (' + PRelease + ')' ">
</asp:AccessDataSource>

【问题讨论】:

【参考方案1】:

在查询中选择 ID,然后选择 DataValueField="ID"。然后您就可以访问值OnSelectedIndexChanged。它将存储在DropDownList2.SelectedValue

【讨论】:

以上是关于在使用表中的连接列值填充列表框时,如何检索相应的 ID 并传递值 onchange [关闭]的主要内容,如果未能解决你的问题,请参考以下文章