Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 根据登录的用户更改SqlDataSource SelectCommand_Html_Asp.net_Vb.net_Sqldatasource - Fatal编程技术网

Html 根据登录的用户更改SqlDataSource SelectCommand

Html 根据登录的用户更改SqlDataSource SelectCommand,html,asp.net,vb.net,sqldatasource,Html,Asp.net,Vb.net,Sqldatasource,我有一个现有的SqlDataSource,但是查询需要根据登录的用户进行更改 <asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="SELECT [id], [text] FROM [tblLinks]" 您可以像更改代码隐藏中的任何其他属性一样更改SelectCommand属性 Protected Sub Page_Load(ByVal sender As Object, ByVal e As Even

我有一个现有的
SqlDataSource
,但是查询需要根据登录的用户进行更改

<asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="SELECT [id], [text] FROM [tblLinks]"

您可以像更改代码隐藏中的任何其他属性一样更改
SelectCommand
属性

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    If (user = "john.doe") Then
        SqlDataSource1.SelectCommand = "SELECT [id], [text] FROM [tblLinks] WHERE text <> 'Admin'"
    Else
        SqlDataSource1.SelectCommand = "SELECT [id], [text] FROM [tblLinks]"
    End If

End Sub
Protected Sub Page_Load(ByVal sender作为对象,ByVal e作为事件参数)
如果(user=“john.doe”),则
SqlDataSource1.SelectCommand=“从[tblLinks]中选择[id],[text],其中文本为“Admin”
否则
SqlDataSource1.SelectCommand=“从[tblLinks]中选择[id],[text]”
如果结束
端接头

如果这有帮助的话,我认为最好是你回顾一下

select...case statement

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    If (user = "john.doe") Then
        SqlDataSource1.SelectCommand = "SELECT [id], [text] FROM [tblLinks] WHERE text <> 'Admin'"
    Else
        SqlDataSource1.SelectCommand = "SELECT [id], [text] FROM [tblLinks]"
    End If

End Sub
select...case statement