猿问

怎样获取DropDownList中DataValueField所绑定的值

<asp:DropDownList ID="MotorcadeDropDownList" runat="server" Style="width: 100px"
                            DataSourceID="MotorcadeNameODS" DataTextField="MotorcadeName" 
                                DataValueField="MotorcadeID">
                            </asp:DropDownList>
                            <asp:ObjectDataSource ID="MotorcadeNameODS" runat="server" SelectMethod="GetMotorcades"
                                TypeName="BLL.Motorcade"></asp:ObjectDataSource>

就上面的几行代码,页面显示的是可以下拉选取MotorcadeName的值,但是我想在提交服务器时获取的是ID值(MotorcadeID),并将其插入到另一张表中,作为外键关联,可是不知道怎么在后台获取已经绑定好了的DropDownList的DataValueField所绑定的ID值,很急啊


慕运维8079593
浏览 845回答 2
2回答
随时随地看视频慕课网APP
我要回答