I have a SQL query that will result in one string. Rather than bind a gridview, listview, etc to it and have a single lonely label inside, I just want to store the string (it'll eventually get used later elsewhere). For the life of me I cannot figure this out.
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="select [title] from [books]
where([Genre]=@Genre)
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;
}
All this does is spit out '0' when I want it to display the title. If I change ["@Title"] to [1], it'll display the Genre. Right now there are only four books, each with a unique genre.