我想使用TextBox1值从SqlDataSource标签中选择数据到gridview。如何修改文件背后的ASP.net代码。
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
SelectCommand= "select distinct [Species],[qty],[received],[Discard],[mortility],[dispatch],[dispatch],[dpt_sales] from [vw_getFishDtls] where [Tank_id]=TextBox1.Text and [ftype] =(select [ftype] from [vw_getFishType] where [Tank_id]=TextBox1.Text"
ConnectionString="Data Source=IT-ISHAN;Initial Catalog=ETF;User Id=ishanuk77; Password=ishanuk77;">
</asp:SqlDataSource>
答案 0 :(得分:0)
您可以添加ControlParameter
,如下所示
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
SelectCommand= "select distinct [Species],[qty],[received],[Discard],[mortility],[dispatch],[dispatch],[dpt_sales] from [vw_getFishDtls] where [Tank_id]=TextBox1.Text and [ftype] =(select [ftype] from [vw_getFishType] where [Tank_id]=@Tank_id"
ConnectionString="Data Source=IT-ISHAN;Initial Catalog=ETF;User Id=ishanuk77; Password=ishanuk77;">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox1" Name="Tank_id"
PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>