sqldatasource取不到值
请各位帮我看看下面代码的问题,如果直接在label1的text中赋值,则下拉列表有结果,但是如果把值先赋给字符串,再把字符串赋给label,下拉就得不到结果,我觉得应该是sqldatasource取不到值得原因。
<%
string s = "2012-3";
Label1.Text = s;
%>
<asp:Label ID="Label1" runat="server"></asp:Label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:attendanceConnectionString %>"
SelectCommand="SELECT [id] FROM [paiban] WHERE ([att_data] = @att_data)">
<SelectParameters>
<asp:ControlParameter ControlID="Label1" Name="att_data" PropertyName="Text"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="id" DataValueField="id">
</asp:DropDownList>
------解决方案--------------------
你这说不通啊,改成这样呢
SelectCommand="select id from paiban where att_data = '"+s+"'"