2016-04-23 78 views
0

我有一个dropdownlist(autopostback启用)在我的项目绑定通过sqldatasource,我已经使用列表项添加了一个初始值。问题是即使选择了我不想要的初始值,页面也会被回发。有没有办法做到这一点?停止autopost返回默认值dropdownlist asp.net

<asp:DropDownList ID="DropDownListTheme" runat="server" 
DataSourceID="SqlDataSourceTheme" DataTextField="h_theme" 
DataValueField="h_theme" Height="30px" Width="30%" 
AppendDataBoundItems="true" AutoPostBack="True"> 
<asp:ListItem Text="--Select One--" Value="-1" /> 
</asp:DropDownList> 
+0

你的意思是你想在回发后选择初始值吗? –

+0

谢谢队友,我已经得到了我的答案。 –

回答

0

为最初选择

<asp:ListItem Text="--Select One--" Selected="True" Value="-1" />

+0

感谢您的hlp。我得到了我正在寻找的, –

0

添加

onchange="if(this.selectedIndex == 0)return false;" 

事件下拉列表中设置初始项目。

+0

非常感谢,这正是我一直在寻找的。 –