I may or may not have a pretty simple question here for you guys. Basing my if-else statements off of the existence of a string, I am trying to either call a SELECT statement with a parameter or not and pass them both to the same resulting GridView.
Here is what I am trying to do:
string query;
if(BadgeNumLabel.Text != "")
{
query = "SELECT * FROM AUDITS";
else
{
query = "SELECT * FROM AUDITS WHERE BADGENUM = :BadgeNumLabel";
GridDataSource.SelectParameters.Add(new Parameter("BadgeNumLabel",TypeCode.String, BadgeNumLabel.Text));
}
GridDataSource.SelectCommand = query;
GridView1.DataBind();
My .aspx code looks like this:
<asp:SqlDataSource ID="GridDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:OracleConnectionString %>"
ProviderName="<%$ ConnectionStrings:OracleConnectionString.ProviderName %>"
onselecting="GridDataSource_Selecting">
</asp:SqlDataSource>
Is there something I am missing? I am so stumped. I think it has to do something with passing the parameter BadgeNumLabel around but I'm not sure.
Any help is greatly appreciated! Thanks!