初始选定头像1:
<asp:listitem  value="m04" Selected="True">头像1</asp:listitem>

解决方案 »

  1.   

    初始选定头像1: 
    <asp:listitem    value="m04"  Selected="True">头像1</asp:listitem> 这样我也试过了!不行。
    我的要求是通过
    <p  align="center"><img  border="0"  src="face/<%#  ListBox_face.selectedItem.Value  %>.gif"  
    这一句来显示出图片,但是一开始怎么也获取不到初始值,该如何设呢??
      

  2.   

    把<img做成一个RunAtServer的控件,然后在代码里指定其src。
      

  3.   

    试试
    <asp:listitem  value="m04" selected="ture" >头像1</asp:listitem>
      

  4.   

    icyer能不能给个例子呢!感谢!
      

  5.   

    修改这一句:
    <img border="0" src="face/<%# ListBox_face.selectedItem.Value %>.gif">
    改为:
    <img src='' runat="server" id="img1" border="0">
    然后在代码中这样给控件赋值:
    img1.Src=Server.MapPath("ciba1b.bmp");
      

  6.   

    哦,你别看错了!
    HTML中的src后面不是引号,而是两个单引号。当然,也可以是两个引号或者干脆不写src。
      

  7.   

    通过服务器端, 用
    dropdownlist.selectedindex = dropdownlist.items.indexof(new listitem("string1"));
    但string1 要在dropdownlist中包含
      

  8.   

    用dropdownlist.selectedindex = dropdownlist.items.indexof(new listitem("string1"),index); 
      

  9.   

    应该这样dropdownlist.selectedindex = dropdownlist.items.indexof(new listitem("string1",index));