前台代码:
<asp:TemplateField HeaderText="性别" SortExpression="Sex">
<EditItemTemplate>
<asp:DropDownList ID="ddlSex" runat="server" SelectedValue='<%# Eval("Sex") %>'>
    <asp:ListItem Text="男">男</asp:ListItem>
    <asp:ListItem Text="女">女</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
   <asp:Label ID="Label5" runat="server" Text='<%# Bind("Sex") %>'></asp:Label>
</ItemTemplate>后台代码:
 DropDownList ddlSex = (DropDownList)dvUser.FindControl("ddlSex");        string Sex = ddlSex.SelectedItem.Text ;

解决方案 »

  1.   

    还是那句老话
    绑定repeater或者gridview数据时,有没有在Page_Load里面加if(!IsPostBack)判断
      

  2.   

    我看微软应该再生成页面cs代码的时候自动加上个PostBack的方法。。
      

  3.   

    string Sex = ddlSex.SelectedValue;
      

  4.   

    http://blog.csdn.net/xianfajushi/archive/2008/11/30/3413317.aspx
      

  5.   

    <asp:DropDownList ID="ddlSex" runat="server" SelectedValue=' <%# Eval("Sex") %>'> 
        <asp:ListItem >男 </asp:ListItem> 
        <asp:ListItem >女 </asp:ListItem> 
    </asp:DropDownList> 就可以
      

  6.   

    你的<asp:ListItem Text="男">男 </asp:ListItem> 怎么这样写啊
    写成<asp:ListItem value="男">男 </asp:ListItem>
    或者<asp:ListItem男 </asp:ListItem>
      

  7.   

    先要找到行,再在行中用findcontrol方法,直接找是找的整个表的第一个