2017-07-02 180 views
0

我在asp中有下面的下拉列表:它綁定到SQL數據庫來檢索基於查詢的值。重置ASP下拉列表AppendDataBoundItems

<td> 
<asp:DropDownList ID="DropDownList4" runat="server" AppendDataBoundItems="true" 
    DataSourceID="SqlDataSource1" DataTextField="VALUE" DataValueField="VALUE"> 
    <asp:ListItem Value=" " Selected="true" Text="--Select One--"></asp:ListItem> 
</asp:DropDownList> 
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
    ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
    SelectCommand="SELECT &quot;VALUE&quot; FROM TABLENAME WHERE (column= xx)"> 
</asp:SqlDataSource> 

的事情是,我想使第一選擇---選擇--- 現在,當我想重置文本框,我想下拉列表重置價值---選擇一個---,在JavaScript中,但我不能。

我重置textfilds在asp.net如下:

document.getElementById('<%= txt_field01.ClientID %>').value = ''; 
document.getElementById('<%= txt_field01.ClientID %>').value = ''; 

我需要你的支持和想法。

回答

0
var drop = document.getElementById('<%=dropdownID.ClientID%>').querySelectorAll("option:selected"); 

你可以使用這個選項之一下面

$(drop).empty(); 

OR

drop.value = ''; 

OR

$('#mydropID').val(''); 
+0

謝謝你的回答,但這並沒有解決它var line給了我無效的參數 –