Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.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
在asp.net中为GridView SqlDataSource动态构建SelectCommand_Asp.net_Sql_Gridview_Select_Sqldatasource - Fatal编程技术网

在asp.net中为GridView SqlDataSource动态构建SelectCommand

在asp.net中为GridView SqlDataSource动态构建SelectCommand,asp.net,sql,gridview,select,sqldatasource,Asp.net,Sql,Gridview,Select,Sqldatasource,我使用的GridView使用的SqlDataSource元素如下所示: <asp:SqlDataSource ID="InventoryDB" runat="server" ConnectionString="<%$ ConnectionStrings:InventoryConnectionString %>" SelectCommand="SELECT [Server], [Customer] FROM [Website] WHERE

我使用的GridView使用的SqlDataSource元素如下所示:

        <asp:SqlDataSource ID="InventoryDB" runat="server" ConnectionString="<%$ ConnectionStrings:InventoryConnectionString %>"
            SelectCommand="SELECT [Server], [Customer] FROM [Website] WHERE [Owner] = 'someOwner'">
        </asp:SqlDataSource>

我想用动态的内容替换where子句中的“someOwner”部分,如下所示:

SelectCommand="SELECT [Server], [Customer] FROM [Website] WHERE [Owner] = '<%# UserManager.getCurrentUser(Request) %>'"
SelectCommand=“从[网站]中选择[服务器],[客户],其中[所有者]=“””

但当我这样做时,它似乎使用WHERE子句的文本,而不是计算我的函数调用,这当然不起作用。正确的方法是什么?

正确的处理方法是使用参数。在演示如何使用它们时,上面的说明非常全面

有一些关于使用参数的更详细和可访问的信息