asp.net dropdownlist 问题
前台代码<asp:DropDownList ID="DropDownList1" runat="server" >
<asp:ListItem Selected="True">2008</asp:ListItem><asp:ListItem >2009</asp:ListItem><asp:ListItem>2010</asp:ListItem>
</asp:DropDownList>
后台string mysql = "select * from chuqin where staffid='"+this.txtID.Text + "',year='"+this .DropDownList1.SelectedValue.ToString ()+
"',month='"+this .DropDownList2.SelectedValue.ToString () +"'"; SqlDataAdapter MyAdapter = new SqlDataAdapter(mysql ,cn );
DataSet MySet = new DataSet(); MyAdapter.Fill(MySet, "chuqin");
this.GridView1.DataSource = MySet;
this.GridView1.DataBind();
请问有什么错误
string mysql = "select * from chuqin where staffid='"+this.txtID.Text + "'芦缺穗游and year='"+this .DropDownList1.SelectedValue.ToString ()+
"'and month='陪族辩"+this .DropDownList2.SelectedValue.ToString () +"'";
string s=DropDownList1.SelectedItem.Text;//这是获取行乎选中的文本值
string s=DropDownList1.SelectedValue//获取DropDownList中你胡肢设定的Value值
你这里面前台只设置了item的text的值 所以档做悉后台应该用DropDownList1.SelectedItem.Text来获取选中的值