我有這個asp在formview插入模板。級聯一個下拉列表與另一個在asp上插入命令
<asp:FormView ID="FormViewReport" runat="server">
<InsertItemTemplate>
GAME_ID:
<asp:DropDownList ID="DropDownListReportIns" runat="server" AutoPostBack="true"
DataSourceID="SqlDataSourceGetGame"
DataTextField="GAME" DataValueField="ID" SelectedValue='<%# Bind("GAME_ID") %>' AppendDataBoundItems="True">
<asp:ListItem Text="ΠΑΡΑΚΑΛΩ ΕΠΙΛΕΞΤΕ ΑΓΩΝΑ" />
</asp:DropDownList>
HOME_PLAYER:
<asp:DropDownList ID="DropDownListRepo" runat="server"
DataSourceID="SqlDataSourceGetPlayers"
DataTextField="HOME_PLAYER_S" DataValueField="HP_ID" SelectedValue='<%# Bind("HOME_PLAYER_ID") %>' >
</asp:DropDownList>
第二下拉列表的數據源的SQL:
<asp:SqlDataSource ID="SqlDataSourceGetPlayers" runat="server" ConnectionString='<%$ ConnectionStrings:BasketballConnectionString1 %>' SelectCommand="SELECT HP.SURNAME blah blah blah WHERE (GAMES.ID = @GAME_ID)">
<SelectParameters>
<asp:ControlParameter ControlID="FormViewReport" PropertyName="SelectedValue" Name="GAME_ID"></asp:ControlParameter>
</SelectParameters>
在第二DROPDOWNLIST查詢需要的GAME_ID參數,這是第一dropdownlist.How我可以從獲得的選定值的DatavalueField第一個下拉列表並將其提供給第二個下拉列表?
我做到了,但是當我改變第一個ddl的值時,它給了我一個錯誤:Eval(),XPath()和Bind()等數據綁定方法只能在數據綁定控件的上下文中使用。 – Apollon
@Aolloll你可以看到哪一塊標記導致了這個錯誤?你是否在頁面的其他地方使用了Eval或Bind,還是僅僅在這兩個DropDownLists中? – jadarnel27
錯誤是:數據綁定方法(如Eval(),XPath()和Bind()只能用於數據綁定控件的上下文中。它顯示在一塊:
Apollon