取dropdownlist 项的VALUE问题
<asp:DropDownList ID= "DropDownList2 " runat= "server ">
<asp:ListItem Value= "idname "> 工号 </asp:ListItem>
<asp:ListItem Value= "name "> 姓名 </asp:ListItem>
</asp:DropDownList> </td>
想取得 "工号 "的VALUE,做查询条件
尝试这样做不行,请指出错误地方:
select * from email where " +this.DropDownList2.SelectedValue.ToString(); + "= ' " + TextBox1.Text.Trim() + " '
------解决方案--------------------string sql
sql= "select * from email where " +this.DropDownList2.SelectedValue.ToString() + "= ' " + TextBox1.Text.Trim() + " ' ";
------解决方案--------------------sql= "select * from email where 工号字段 = ' " +this.DropDownList2.SelectedValue.ToString()+ " '"