日期:2014-05-19  浏览次数:20826 次

请教关于选中dropdownlist选项的问题
我在前台的代码如下:
<asp:DropDownList   ID= "jbdw1 "   runat= "server "   DataSourceID= "SqlDataSource3 "
                                        DataTextField= "dw_name "   DataValueField= "dw_id ">
                                </asp:DropDownList> <asp:SqlDataSource   ID= "SqlDataSource3 "   runat= "server "   ConnectionString= " <%$   ConnectionStrings:connoastr   %> "
                                        ProviderName= " <%$   ConnectionStrings:connoastr.ProviderName   %> "   SelectCommand= "SELECT   *   FROM   [dwlist]   ORDER   BY   [dw_name] ">
                                </asp:SqlDataSource>
.cs文件中我在page_load中加入了这一句:
jbdw1.SelectedIndex   =   jbdw1.Items.IndexOf(jbdw1.Items.FindByValue( "1 "));
程序运行之后生成的代码确实有一项值为1,但是为什么他就不能处于选中状态呢?而是始终显示第一项。

麻烦各位大大帮忙指点一下

------解决方案--------------------
SelectedValue 来控制