我正在尝试创建一个 ASP.NET 网页来输出一个文本框,然后用户将在此文本框中输入密钥,然后我使用该密钥在 SQL 代码中放入 WHERE 条件以输出与该密钥匹配的数据。例如,用户在文本框中输入 ArtistID,我需要使用 SPEEDOFSALEREPORT 打印表格
SELECT * FROM SPEEDOFSALEREPORT WHERE ArtistID = "用户刚刚输入的密钥"
但我不知道怎么做。我下面的代码创建一个文本框并打印表中的所有行。请给我一个提示。我整天都在谷歌上搜索,但找不到答案。谢谢你。
这是我更新的 Default.aspx
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtArtistID" runat="server" /><br /><br />
<asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="submit" />
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="TRANSACTIONID" HeaderText="TRANSACTIONID"
SortExpression="TRANSACTIONID" />
<asp:BoundField DataField="WORKID" HeaderText="WORKID"
SortExpression="WORKID" />
<asp:BoundField DataField="ARTISTID" HeaderText="ARTISTID"
SortExpression="ARTISTID" />
<asp:BoundField DataField="DATEACQUIRED" HeaderText="DATEACQUIRED"
SortExpression="DATEACQUIRED" />
<asp:BoundField DataField="DATESOLDID" HeaderText="DATESOLDID"
SortExpression="DATESOLDID" />
<asp:BoundField DataField="TURNAROUNDDAYS" HeaderText="TURNAROUNDDAYS"
SortExpression="TURNAROUNDDAYS" />
<asp:BoundField DataField="ASKINGPRICE" HeaderText="ASKINGPRICE"
SortExpression="ASKINGPRICE" />
<asp:BoundField DataField="SALESPRICE" HeaderText="SALESPRICE"
SortExpression="SALESPRICE" />
<asp:BoundField DataField="SALESMARGIN" HeaderText="SALESMARGIN"
SortExpression="SALESMARGIN" />
</Columns>
</asp:GridView>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="Data Source=oracle2;User ID=****;Password=****;Unicode=True"
ProviderName="System.Data.OracleClient"
SelectCommand="SELECT * FROM SPEEDOFSALEREPORT WHERE ARTISTID = @artistID;">
<SelectParameters>
<asp:ControlParameter Name="artistID" ControlID="txtArtistID" PropertyName="Text" />
</SelectParameter>
</asp:SqlDataSource>
</form>
</body>