我有一个SQL查询将导致一个字符串。而不是绑定一个gridview,listview等,并且里面只有一个单独的标签,我只想存储这个字符串(它最终会在其他地方使用)。对于我的生活,我无法弄清楚这一点。从SqlDataSource获取查询结果并存储为字符串
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="select [title] from [books]
where([Genre][email protected])
OnSelected="SqlDataSource3_Selected">
<SelectParameters>
<asp:Parameter Name="Title" Direction="ReturnValue" Type="String" />
<asp:ControlParameter ControlID="DropDownList1" Name="genre"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
protected void SqlDataSource3_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
string sqlreturnString = Convert.ToString(e.Command.Parameters["@Title"].Value);
Label3.Text = sqlreturnString;
}
所有这一切都是当我想要显示标题时吐出'0'。如果我将[“@Title”]更改为[1],则会显示流派。现在只有四本书,每本都有独特的风格。
使用[0]怎么样? – Basic