【发布时间】:2018-04-13 06:15:20
【问题描述】:
我一直在尝试在 Visual Studio .net 中填充下拉列表,但每当我尝试在查询中使用文本框时,我一直在使用 Visual Studio 中的配置选择语句向导,尝试时出现错误在 sql select 命令中使用文本框,或者在我测试查询时给出空字段。
<table class="auto-style1">
<tr>
<td class="auto-style1"></td>
<td class="auto-style2">
Select Class:</td>
<td class="auto-style1">
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="ClassName" DataValueField="ClassName"></asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [ClassName] FROM [Classroom] WHERE ([TeacherUsername] = @TeacherUsername)">
<SelectParameters>
<asp:FormParameter FormField="TextBox1.Text" Name="TeacherUsername" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</td>
<td class="auto-style1">
<asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged" Visible="False"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="Label" Visible="False"></asp:Label>
</td>
</tr>
</table>
那么谁能帮我在我的 sql 选择查询中包含我的文本框,谢谢!
【问题讨论】:
标签: sql .net visual-studio