You may also try something like that in Page_Load event:
If condition
{
SqlDataSource1.SelectCommand = "select * from TableA";
}
else
{
SqlDataSource1.SelectCommand = "select * from TableB";
}
Or maybe you can get the result using parameters in your datasource:
<asp:sqldatasource
id="SqlDataSource1"
runat="server"
connectionstring="<%$ ConnectionStrings:MyNorthwind%>"
selectcommand="SELECT * FROM Table WHERE userid = @userid">
<selectparameters>
<asp:parameter name="userid" type="int32" />
</selectparameters>
</asp:sqldatasource>
private void Page_Load(object sender, System.EventArgs e)
{
If condition
{
SqlDataSource1.SelectParameters["userid"].DefaultValue = 123;
}
else
{
SqlDataSource1.SelectParameters["userid"].DefaultValue = 456;
}
}
I hope it is useful.
-----------------------------------------------------------------
My site:
Apartamentos a venda em Guarulhos