I would like to use a selected value of a dropdown list in a SqlDataSource SelectCommand.
<asp:DropDownList ID="ddlSelectRole" runat="server" ClientIDMode="Static">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Client</asp:ListItem>
<asp:ListItem>Programming</asp:ListItem>
<asp:ListItem>Guest</asp:ListItem>
</asp:DropDownList>
Currently:
<asp:SqlDataSource ID="dsourceProgEmails" runat="server"
ConnectionString="<%$ ConnectionStrings:ProjectConnectionString %>"
SelectCommand="SELECT [Email] + ',' AS [text()] FROM [SiteUsers] WHERE [Role] = 'Programming' FOR XML PATH ('')">
</asp:SqlDataSource>
I'm thinking something like:
<asp:SqlDataSource ID="dsourceProgEmails" runat="server"
ConnectionString="<%$ ConnectionStrings:ProjectConnectionString %>"
SelectCommand="SELECT [Email] + ',' AS [text()] FROM [SiteUsers] WHERE [Role] = '" + ddlSelectRole.SelectedValue + "' FOR XML PATH ('')">
</asp:SqlDataSource>
Code-behind is C#.